|
@@ -463,9 +463,21 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs) {
|
|
|
|
|
|
# Add error bars if specified
|
|
|
if (!is.null(config$error_bar) && config$error_bar) {
|
|
|
- error_bar_color <- config$error_bar_params$color %||% "red"
|
|
|
- y_mean_col <- paste0("mean_", config$y_var)
|
|
|
- y_sd_col <- paste0("sd_", config$y_var)
|
|
|
+ error_bar_color <- if (!is.null(config$error_bar_params$color)) {
|
|
|
+ config$error_bar_params$color
|
|
|
+ } else {
|
|
|
+ "red"
|
|
|
+ }
|
|
|
+
|
|
|
+ y_mean_col <- paste0("mean_mean_", config$y_var)
|
|
|
+
|
|
|
+ # Dynamically set y_sd_col based on the provided prefix in error_bar_params
|
|
|
+ y_sd_prefix <- if (!is.null(config$error_bar_params$y_sd_prefix)) {
|
|
|
+ config$error_bar_params$y_sd_prefix
|
|
|
+ } else {
|
|
|
+ "sd_"
|
|
|
+ }
|
|
|
+ y_sd_col <- paste0(y_sd_prefix, config$y_var)
|
|
|
|
|
|
if (!is.null(config$error_bar_params$center_point)) {
|
|
|
plot <- plot + geom_point(aes(
|
|
@@ -489,6 +501,8 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
# Convert ggplot to plotly for interactive version
|
|
|
plotly_plot <- suppressWarnings(plotly::ggplotly(plot))
|
|
|
|
|
@@ -511,19 +525,18 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs) {
|
|
|
nrow = grid_layout$nrow
|
|
|
)
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
# Close the PDF device after all plots are done
|
|
|
dev.off()
|
|
|
|
|
|
# Save HTML file with interactive plots if needed
|
|
|
- # out_html_file <- file.path(out_dir, paste0(filename, ".html"))
|
|
|
- # message("Saving combined HTML file: ", out_html_file)
|
|
|
- # htmltools::save_html(
|
|
|
- # htmltools::tagList(plotly_plots),
|
|
|
- # file = out_html_file
|
|
|
- # )
|
|
|
+ out_html_file <- file.path(out_dir, paste0(filename, ".html"))
|
|
|
+ message("Saving combined HTML file: ", out_html_file)
|
|
|
+ htmltools::save_html(
|
|
|
+ htmltools::tagList(plotly_plots),
|
|
|
+ file = out_html_file
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
generate_scatter_plot <- function(plot, config) {
|
|
@@ -650,7 +663,7 @@ generate_scatter_plot <- function(plot, config) {
|
|
|
label = annotation$label,
|
|
|
hjust = ifelse(is.null(annotation$hjust), 0.5, annotation$hjust),
|
|
|
vjust = ifelse(is.null(annotation$vjust), 0.5, annotation$vjust),
|
|
|
- size = ifelse(is.null(annotation$size), 6, annotation$size),
|
|
|
+ size = ifelse(is.null(annotation$size), 3, annotation$size),
|
|
|
color = ifelse(is.null(annotation$color), "black", annotation$color)
|
|
|
)
|
|
|
}
|
|
@@ -759,6 +772,7 @@ generate_interaction_plot_configs <- function(df, type) {
|
|
|
plot_config$title <- sprintf("%s Scatter RF for %s with SD", OrfRep, var)
|
|
|
plot_config$error_bar <- TRUE
|
|
|
plot_config$error_bar_params <- list(
|
|
|
+ y_sd_prefix = "WT_sd_",
|
|
|
color = "red",
|
|
|
center_point = TRUE
|
|
|
)
|