Browse Source

Paginate plot groups

Bryan Roessler 7 tháng trước cách đây
mục cha
commit
5332cf3fbc
1 tập tin đã thay đổi với 8 bổ sung2 xóa
  1. 8 2
      qhtcp-workflow/apps/r/calculate_interaction_zscores.R

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

@@ -415,6 +415,7 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs) {
   # Open the PDF device once for all plots
   pdf(file.path(out_dir, paste0(filename, ".pdf")), width = 16, height = 9)
 
+  # Loop through each plot group
   for (group in plot_groups) {
     static_plots <- list()
     plotly_plots <- list()
@@ -496,7 +497,7 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs) {
       plotly_plots[[i]] <- plotly_plot
     }
 
-    # Print the plots to the PDF (one page per plot or in a grid)
+    # Print the plots in the current group to the PDF
     if (is.null(grid_layout)) {
       # Print each plot individually on separate pages if no grid layout is specified
       for (plot in static_plots) {
@@ -510,12 +511,17 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs) {
         nrow = grid_layout$nrow
       )
     }
+
+    # Add a new page for the next group, if it exists
+    if (length(plot_groups) > 1) {
+      grid.newpage()
+    }
   }
 
   # Close the PDF device after all plots are done
   dev.off()
 
-  # Optional: Uncomment and save the interactive HTML version if needed
+  # Save HTML file with interactive plots if needed
   # out_html_file <- file.path(out_dir, paste0(filename, ".html"))
   # message("Saving combined HTML file: ", out_html_file)
   # htmltools::save_html(