Add exception for delta_bg plot
This commit is contained in:
@@ -157,8 +157,10 @@ update_gene_names <- function(df, sgd_gene_list) {
|
||||
}
|
||||
|
||||
generate_plot <- function(df, x_var, y_var = NULL, plot_type, color_var = "conc_num", title, x_label = NULL, y_label = NULL) {
|
||||
plot <- ggplot(df, aes(x = {{x_var}}, y = {{y_var}}, color = {{color_var}}))
|
||||
# Base ggplot object
|
||||
plot <- ggplot(df, aes(x = {{x_var}}, color = {{color_var}}))
|
||||
|
||||
# Handle different plot types
|
||||
if (plot_type == "scatter") {
|
||||
plot <- plot + geom_point(shape = 3, size = 0.2, position = "jitter") +
|
||||
stat_summary(fun.data = mean_sdl, geom = "errorbar") +
|
||||
@@ -166,19 +168,22 @@ generate_plot <- function(df, x_var, y_var = NULL, plot_type, color_var = "conc_
|
||||
} else if (plot_type == "box") {
|
||||
plot <- plot + geom_boxplot()
|
||||
} else if (plot_type == "density") {
|
||||
plot <- plot + geom_density()
|
||||
plot <- plot + geom_density() # Density plot automatically maps density to y
|
||||
} else if (plot_type == "bar") {
|
||||
plot <- plot + geom_bar(stat = "identity")
|
||||
}
|
||||
|
||||
# Add titles and labels
|
||||
plot <- plot + ggtitle(title) + theme_publication()
|
||||
|
||||
# Add optional labels if provided
|
||||
if (!is.null(x_label)) plot <- plot + xlab(x_label)
|
||||
if (!is.null(y_label)) plot <- plot + ylab(y_label)
|
||||
|
||||
return(plot)
|
||||
}
|
||||
|
||||
|
||||
generate_and_save_plots <- function(df, output_dir, prefix, variables, include_qc = FALSE) {
|
||||
plots <- list()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user