瀏覽代碼

Add theme_publication() to generate_and_save_plots()

Bryan Roessler 7 月之前
父節點
當前提交
a45b977b0d
共有 1 個文件被更改,包括 4 次插入10 次删除
  1. 4 10
      qhtcp-workflow/apps/r/calculate_interaction_zscores.R

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

@@ -394,7 +394,7 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs, grid_layout
     }
 
     # Start building the plot with aes_mapping
-    plot_base <- ggplot(df, aes_mapping) + theme_publication()
+    plot_base <- ggplot(df, aes_mapping)
 
     # Use appropriate helper function based on plot type
     plot <- switch(config$plot_type,
@@ -405,10 +405,9 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs, grid_layout
       plot_base  # default case if no type matches
     )
 
-    # Apply additional settings
-    if (!is.null(config$legend_position)) {
-      plot <- plot + theme(legend.position = config$legend_position)
-    }
+    # Apply theme_publication with legend_position from config
+    legend_position <- if (!is.null(config$legend_position)) config$legend_position else "bottom"
+    plot <- plot + theme_publication(legend_position = legend_position)
 
     # Add title and labels
     if (!is.null(config$title)) {
@@ -615,11 +614,6 @@ generate_scatter_plot <- function(plot, config) {
     plot <- plot + ggtitle(config$title)
   }
   
-  # Adjust Legend Position if specified
-  if (!is.null(config$legend_position)) {
-    plot <- plot + theme(legend.position = config$legend_position)
-  }
-  
   return(plot)
 }