Restore default aes colors

This commit is contained in:
2024-09-30 01:48:50 -04:00
parent 2f42357aa1
commit 039c6c1388

View File

@@ -151,7 +151,7 @@ load_and_filter_data <- function(easy_results_file, sd = 3) {
OrfRep = if_else(ORF == "YDL227C", "YDL227C", OrfRep), # should these be hardcoded?
conc_num = as.numeric(gsub("[^0-9\\.]", "", Conc)),
conc_num_factor = as.numeric(as.factor(conc_num)) - 1, # for legacy purposes
conc_num_factor_factor = factor(conc_num)
conc_num_factor_factor = as.factor(conc_num)
)
return(df)
@@ -405,12 +405,23 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs) {
# Define aes_mapping and handle color_var defaulting
aes_mapping <- if (config$plot_type == "bar") {
aes(x = .data[[config$x_var]], fill = ifelse(!is.null(config$color_var), .data[[config$color_var]], "black"),
color = ifelse(!is.null(config$color_var), .data[[config$color_var]], "black"))
if (!is.null(config$color_var)) {
aes(x = .data[[config$x_var]], fill = .data[[config$color_var]], color = .data[[config$color_var]])
} else {
aes(x = .data[[config$x_var]])
}
} else if (config$plot_type == "density") {
aes(x = .data[[config$x_var]], color = ifelse(!is.null(config$color_var), .data[[config$color_var]], "black"))
if (!is.null(config$color_var)) {
aes(x = .data[[config$x_var]], color = .data[[config$color_var]])
} else {
aes(x = .data[[config$x_var]])
}
} else {
aes(x = .data[[config$x_var]], y = .data[[config$y_var]], color = ifelse(!is.null(config$color_var), .data[[config$color_var]], "black"))
if (!is.null(config$color_var)) {
aes(x = .data[[config$x_var]], y = .data[[config$y_var]], color = .data[[config$color_var]])
} else {
aes(x = .data[[config$x_var]], y = .data[[config$y_var]])
}
}
# Apply theme_publication with legend_position
@@ -451,7 +462,11 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs) {
dev.off()
# Save combined interactive HTML plots
combined_plot <- plotly::subplot(plotly_plots, nrows = grid_nrow, ncols = grid_ncol, margin = 0.05)
if (length(plotly_plots) == 1) {
combined_plot <- plotly_plots[[1]]
} else {
combined_plot <- plotly::subplot(plotly_plots, nrows = grid_nrow, ncols = grid_ncol, margin = 0.05)
}
html_file <- file.path(out_dir, paste0(filename, ".html"))
saveWidget(combined_plot, file = html_file, selfcontained = TRUE)
}