Skip nullgrob() since plot generation provides full chunks
This commit is contained in:
@@ -597,13 +597,13 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs, page_width
|
|||||||
grid_layout$nrow <- ceiling(num_plots / grid_layout$ncol)
|
grid_layout$nrow <- ceiling(num_plots / grid_layout$ncol)
|
||||||
}
|
}
|
||||||
|
|
||||||
total_spots <- grid_layout$nrow * grid_layout$ncol
|
# total_spots <- grid_layout$nrow * grid_layout$ncol
|
||||||
num_plots <- length(static_plots)
|
# num_plots <- length(static_plots)
|
||||||
|
|
||||||
if (num_plots < total_spots) {
|
# if (num_plots < total_spots) {
|
||||||
message("Filling ", total_spots - num_plots, " empty spots with nullGrob()")
|
# message("Filling ", total_spots - num_plots, " empty spots with nullGrob()")
|
||||||
static_plots <- c(static_plots, replicate(total_spots - num_plots, nullGrob(), simplify = FALSE))
|
# static_plots <- c(static_plots, replicate(total_spots - num_plots, nullGrob(), simplify = FALSE))
|
||||||
}
|
# }
|
||||||
|
|
||||||
grid.arrange(
|
grid.arrange(
|
||||||
grobs = static_plots,
|
grobs = static_plots,
|
||||||
@@ -739,9 +739,6 @@ generate_scatter_plot <- function(plot, config) {
|
|||||||
slope <- config$lm_line$slope
|
slope <- config$lm_line$slope
|
||||||
color <- ifelse(!is.null(config$lm_line$color), config$lm_line$color, "blue")
|
color <- ifelse(!is.null(config$lm_line$color), config$lm_line$color, "blue")
|
||||||
linewidth <- ifelse(!is.null(config$lm_line$linewidth), config$lm_line$linewidth, 1)
|
linewidth <- ifelse(!is.null(config$lm_line$linewidth), config$lm_line$linewidth, 1)
|
||||||
|
|
||||||
# Ensure none of the values are NA and calculate y-values
|
|
||||||
if (!is.na(x_min) && !is.na(x_max) && !is.na(intercept) && !is.na(slope)) {
|
|
||||||
y_min <- intercept + slope * x_min
|
y_min <- intercept + slope * x_min
|
||||||
y_max <- intercept + slope * x_max
|
y_max <- intercept + slope * x_max
|
||||||
|
|
||||||
@@ -752,8 +749,6 @@ generate_scatter_plot <- function(plot, config) {
|
|||||||
|
|
||||||
# Adjust or skip based on whether the values fall within limits
|
# Adjust or skip based on whether the values fall within limits
|
||||||
if (y_min_within_limits && y_max_within_limits) {
|
if (y_min_within_limits && y_max_within_limits) {
|
||||||
# Ensure x-values are also valid
|
|
||||||
if (!is.na(x_min) && !is.na(x_max)) {
|
|
||||||
plot <- plot + annotate(
|
plot <- plot + annotate(
|
||||||
"segment",
|
"segment",
|
||||||
x = x_min,
|
x = x_min,
|
||||||
@@ -763,7 +758,6 @@ generate_scatter_plot <- function(plot, config) {
|
|||||||
color = color,
|
color = color,
|
||||||
linewidth = linewidth
|
linewidth = linewidth
|
||||||
)
|
)
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
message("Skipping linear regression line due to y-values outside of limits")
|
message("Skipping linear regression line due to y-values outside of limits")
|
||||||
}
|
}
|
||||||
@@ -779,9 +773,6 @@ generate_scatter_plot <- function(plot, config) {
|
|||||||
linewidth = linewidth
|
linewidth = linewidth
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
message("Skipping linear regression line due to missing or invalid values")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add SD Bands if specified
|
# Add SD Bands if specified
|
||||||
@@ -1485,7 +1476,7 @@ main <- function() {
|
|||||||
|
|
||||||
message("Generating quality control plots in parallel")
|
message("Generating quality control plots in parallel")
|
||||||
# future::plan(future::multicore, workers = parallel::detectCores())
|
# future::plan(future::multicore, workers = parallel::detectCores())
|
||||||
future::plan(future::multisession, workers = 3) # generate 3 plots in parallel
|
future::plan(future::multisession, workers = 3) # generate 3 plot files in parallel
|
||||||
|
|
||||||
plot_configs <- list(
|
plot_configs <- list(
|
||||||
list(out_dir = out_dir_qc, filename = "L_vs_K_before_quality_control",
|
list(out_dir = out_dir_qc, filename = "L_vs_K_before_quality_control",
|
||||||
|
|||||||
Reference in New Issue
Block a user