فهرست منبع

Use more precalculated values in plots

Bryan Roessler 7 ماه پیش
والد
کامیت
d010f52e85
1فایلهای تغییر یافته به همراه8 افزوده شده و 2 حذف شده
  1. 8 2
      qhtcp-workflow/apps/r/calculate_interaction_zscores.R

+ 8 - 2
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(),