Add back error bars to scatter plots
This commit is contained in:
@@ -471,6 +471,16 @@ generate_scatter_plot <- function(plot, config, interactive = FALSE) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Add error bars if specified
|
||||||
|
if (!is.null(config$error_bar) && config$error_bar) {
|
||||||
|
y_mean_col <- paste0("mean_", config$y_var)
|
||||||
|
y_sd_col <- paste0("sd_", config$y_var)
|
||||||
|
plot <- plot + geom_errorbar(aes(
|
||||||
|
ymin = !!sym(y_mean_col) - !!sym(y_sd_col),
|
||||||
|
ymax = !!sym(y_mean_col) + !!sym(y_sd_col)
|
||||||
|
), alpha = 0.3)
|
||||||
|
}
|
||||||
|
|
||||||
# Add x-axis customization if specified
|
# Add x-axis customization if specified
|
||||||
if (!is.null(config$x_breaks) && !is.null(config$x_labels) && !is.null(config$x_label)) {
|
if (!is.null(config$x_breaks) && !is.null(config$x_labels) && !is.null(config$x_label)) {
|
||||||
plot <- plot + scale_x_continuous(
|
plot <- plot + scale_x_continuous(
|
||||||
@@ -615,10 +625,7 @@ generate_interaction_plot_configs <- function(df, variables) {
|
|||||||
ylim_vals = var_info$ylim,
|
ylim_vals = var_info$ylim,
|
||||||
annotations = annotations,
|
annotations = annotations,
|
||||||
lm_line = lm_line, # Precomputed linear model
|
lm_line = lm_line, # Precomputed linear model
|
||||||
error_bar = list(
|
error_bar = TRUE,
|
||||||
ymin = 0 - (2 * df[[var_info$sd_col]][1]),
|
|
||||||
ymax = 0 + (2 * df[[var_info$sd_col]][1])
|
|
||||||
),
|
|
||||||
x_breaks = unique(df$conc_num_factor),
|
x_breaks = unique(df$conc_num_factor),
|
||||||
x_labels = unique(as.character(df$conc_num)),
|
x_labels = unique(as.character(df$conc_num)),
|
||||||
x_label = unique(df$Drug[1]),
|
x_label = unique(df$Drug[1]),
|
||||||
@@ -637,7 +644,7 @@ generate_interaction_plot_configs <- function(df, variables) {
|
|||||||
title = sprintf("%s %s (Boxplot)", df$OrfRep[1], df$Gene[1]),
|
title = sprintf("%s %s (Boxplot)", df$OrfRep[1], df$Gene[1]),
|
||||||
ylim_vals = var_info$ylim,
|
ylim_vals = var_info$ylim,
|
||||||
annotations = annotations,
|
annotations = annotations,
|
||||||
error_bar = FALSE, # Boxplots typically don't need error bars
|
error_bar = FALSE,
|
||||||
x_breaks = unique(df$conc_num_factor),
|
x_breaks = unique(df$conc_num_factor),
|
||||||
x_labels = unique(as.character(df$conc_num)),
|
x_labels = unique(as.character(df$conc_num)),
|
||||||
x_label = unique(df$Drug[1]),
|
x_label = unique(df$Drug[1]),
|
||||||
|
|||||||
Reference in New Issue
Block a user