From d010f52e8565cfc1960fb0e527146019c596db69 Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Thu, 12 Sep 2024 00:59:43 -0400 Subject: [PATCH] Use more precalculated values in plots --- qhtcp-workflow/apps/r/calculate_interaction_zscores.R | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qhtcp-workflow/apps/r/calculate_interaction_zscores.R b/qhtcp-workflow/apps/r/calculate_interaction_zscores.R index c24c504c..c17904be 100644 --- a/qhtcp-workflow/apps/r/calculate_interaction_zscores.R +++ b/qhtcp-workflow/apps/r/calculate_interaction_zscores.R @@ -368,7 +368,13 @@ generate_and_save_plots <- function(output_dir, file_name, plot_configs, grid_la } if (!is.null(config$add_smooth) && config$add_smooth) { - plot <- plot + geom_smooth(method = "lm", se = FALSE) + if (!is.null(config$lm_line)) { + # Use precomputed linear model values if available + plot <- plot + geom_abline(intercept = config$lm_line$intercept, slope = config$lm_line$slope) + } else { + # Fallback to dynamically calculating the smooth line + plot <- plot + geom_smooth(method = "lm", se = FALSE) + } } plot <- plot + @@ -405,7 +411,7 @@ generate_and_save_plots <- function(output_dir, file_name, plot_configs, grid_la }, "correlation" = plot + geom_point(shape = config$shape %||% 3, color = "gray70") + - geom_smooth(method = "lm", color = "tomato3") + + geom_abline(intercept = config$lm_line$intercept, slope = config$lm_line$slope, color = "tomato3") + annotate("text", x = 0, y = 0, label = config$correlation_text), "box" = plot + geom_boxplot(),