From e85610285174ba5e0874d9182b78aca9ab3349fc Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Wed, 2 Oct 2024 14:05:39 -0400 Subject: [PATCH] Fix default error bar calculations --- .../apps/r/calculate_interaction_zscores.R | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/qhtcp-workflow/apps/r/calculate_interaction_zscores.R b/qhtcp-workflow/apps/r/calculate_interaction_zscores.R index 4a727060..e09c199a 100644 --- a/qhtcp-workflow/apps/r/calculate_interaction_zscores.R +++ b/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 }