diff --git a/workflow/apps/r/calculate_interaction_zscores5.R b/workflow/apps/r/calculate_interaction_zscores5.R index 8e96c4d9..c3f4422e 100644 --- a/workflow/apps/r/calculate_interaction_zscores5.R +++ b/workflow/apps/r/calculate_interaction_zscores5.R @@ -87,7 +87,6 @@ theme_publication <- function(base_size = 14, base_family = "sans", legend_posit ) } - scale_fill_publication <- function(...) { discrete_scale("fill", "Publication", manual_pal(values = c( "#386cb0", "#fdb462", "#7fc97f", "#ef3b2c", "#662506", @@ -270,14 +269,21 @@ save_plots <- function(file_name, plot_list, output_dir) { # Save to HTML with horizontal legend orientation lapply(names(plot_list), function(plot_name) { - pgg <- suppressWarnings(ggplotly(plot_list[[plot_name]]) %>% - layout(legend = list(orientation = "h"))) + message("Processing plot: ", plot_name) + pgg <- tryCatch({ + suppressWarnings(ggplotly(plot_list[[plot_name]]) %>% + layout(legend = list(orientation = "h"))) + }, error = function(e) { + message("Error in plot: ", plot_name, "\n", e) + return(NULL) + }) - saveWidget( - pgg, - file = file.path(output_dir, - paste0(file_name, "_", plot_name, ".html")), - selfcontained = TRUE) + if (!is.null(pgg)) { + saveWidget(pgg, + file = file.path(output_dir, + paste0(file_name, "_", plot_name, ".html")), + selfcontained = TRUE) + } }) }