diff --git a/workflow/apps/r/calculate_interaction_zscores5.R b/workflow/apps/r/calculate_interaction_zscores5.R index 82e131c1..828f3cb8 100644 --- a/workflow/apps/r/calculate_interaction_zscores5.R +++ b/workflow/apps/r/calculate_interaction_zscores5.R @@ -193,6 +193,13 @@ generate_plot <- function(df, x_var, y_var = NULL, plot_type, color_var = "conc_ generate_and_save_plots <- function(df, output_dir, prefix, variables, include_qc = FALSE) { plots <- list() + + if (nrow(df) == 0) { + message("The \"", deparse(substitute(df)), "\" dataframe is empty, skipping plots") + return() + } + + message("Generating plots for \"", deparse(substitute(df)), "\" dataframe") for (var in variables) { scatter_plot <- @@ -269,7 +276,7 @@ save_plots <- function(file_name, plot_list, output_dir) { # Save to HTML with horizontal legend orientation lapply(names(plot_list), function(plot_name) { - message("Processing plot: ", plot_name) + message("Generating plot: ", plot_name) pgg <- tryCatch({ suppressWarnings(ggplotly(plot_list[[plot_name]]) %>% layout(legend = list(orientation = "h")))