Browse Source

Fix default error bar calculations

Bryan Roessler 6 months ago
parent
commit
e856102851
1 changed files with 8 additions and 10 deletions
  1. 8 10
      qhtcp-workflow/apps/r/calculate_interaction_zscores.R

+ 8 - 10
qhtcp-workflow/apps/r/calculate_interaction_zscores.R

@@ -468,23 +468,21 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs) {
 
         # Use error_bar_params if provided, otherwise calculate from mean and sd
         if (!is.null(config$error_bar_params$ymin) && !is.null(config$error_bar_params$ymax)) {
-          ymin_value <- config$error_bar_params$ymin
-          ymax_value <- config$error_bar_params$ymax
+          plot <- plot + geom_errorbar(aes(
+            ymin = config$error_bar_params$ymin,
+            ymax = config$error_bar_params$ymax,
+            color = error_bar_color))
         } else {
           y_mean_col <- paste0("mean_", config$y_var)
           y_sd_col <- paste0("sd_", config$y_var)
-          ymin_value <- df[[y_mean_col]] - df[[y_sd_col]]
-          ymax_value <- df[[y_mean_col]] + df[[y_sd_col]]
+          plot <- plot + geom_errorbar(aes(
+            ymin = .data[[y_mean_col]] - .data[[y_sd_col]],
+            ymax = .data[[y_mean_col]] + .data[[y_sd_col]],
+            color = error_bar_color))
         }
-
-        plot <- plot + geom_errorbar(aes(
-          ymin = ymin_value,
-          ymax = ymax_value,
-          color = error_bar_color))
       }
 
       plotly_plot <- suppressWarnings(plotly::ggplotly(plot))
-
       static_plots[[i]] <- plot
       plotly_plots[[i]] <- plotly_plot
     }