Simplify SD bands
This commit is contained in:
@@ -508,29 +508,27 @@ generate_scatter_plot <- function(plot, config) {
|
||||
}
|
||||
|
||||
# Add SD Bands if specified
|
||||
if (!is.null(config$sd_band_values)) {
|
||||
for (sd_band in config$sd_band_values) {
|
||||
if (!is.null(config$sd_band)) {
|
||||
plot <- plot +
|
||||
annotate(
|
||||
"rect",
|
||||
xmin = -Inf, xmax = Inf,
|
||||
ymin = sd_band, ymax = Inf,
|
||||
ymin = config$sd_band, ymax = Inf,
|
||||
fill = "#542788",
|
||||
alpha = 0.3
|
||||
) +
|
||||
annotate(
|
||||
"rect",
|
||||
xmin = -Inf, xmax = Inf,
|
||||
ymin = -sd_band, ymax = -Inf,
|
||||
ymin = -config$sd_band, ymax = -Inf,
|
||||
fill = "orange",
|
||||
alpha = 0.3
|
||||
) +
|
||||
geom_hline(
|
||||
yintercept = c(-sd_band, sd_band),
|
||||
yintercept = c(-config$sd_band, config$sd_band),
|
||||
color = "gray"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
# Add Rectangles if specified
|
||||
if (!is.null(config$rectangles)) {
|
||||
@@ -770,8 +768,7 @@ generate_rank_plot_configs <- function(df_filtered, variables, is_lm = FALSE) {
|
||||
|
||||
# SD-based plots for L and K
|
||||
for (variable in c("L", "K")) {
|
||||
for (sd_band in sd_bands) {
|
||||
# Determine columns based on whether it's lm or not
|
||||
|
||||
if (is_lm) {
|
||||
rank_var <- paste0("Rank_lm_", variable)
|
||||
zscore_var <- paste0("Z_lm_", variable)
|
||||
@@ -782,6 +779,8 @@ generate_rank_plot_configs <- function(df_filtered, variables, is_lm = FALSE) {
|
||||
y_label <- paste("Avg Z score", variable)
|
||||
}
|
||||
|
||||
for (sd_band in sd_bands) {
|
||||
|
||||
num_enhancers <- sum(df_filtered[[zscore_var]] >= sd_band, na.rm = TRUE)
|
||||
num_suppressors <- sum(df_filtered[[zscore_var]] <= -sd_band, na.rm = TRUE)
|
||||
|
||||
@@ -805,7 +804,6 @@ generate_rank_plot_configs <- function(df_filtered, variables, is_lm = FALSE) {
|
||||
label = paste("Deletion Suppressors =", num_suppressors)
|
||||
)
|
||||
),
|
||||
sd_band_values = sd_band,
|
||||
shape = 3,
|
||||
size = 0.1,
|
||||
y_label = y_label,
|
||||
@@ -822,7 +820,6 @@ generate_rank_plot_configs <- function(df_filtered, variables, is_lm = FALSE) {
|
||||
title = paste(y_label, "vs. Rank for", variable, "above", sd_band, "SD No Annotations"),
|
||||
sd_band = sd_band,
|
||||
annotations = NULL,
|
||||
sd_band_values = sd_band,
|
||||
shape = 3,
|
||||
size = 0.1,
|
||||
y_label = y_label,
|
||||
@@ -873,7 +870,6 @@ generate_rank_plot_configs <- function(df_filtered, variables, is_lm = FALSE) {
|
||||
label = paste("R-squared =", round(lm_summary$r.squared, 2))
|
||||
)
|
||||
),
|
||||
sd_band_values = NULL, # Not applicable
|
||||
shape = 3,
|
||||
size = 0.1,
|
||||
add_smooth = TRUE,
|
||||
@@ -997,7 +993,6 @@ filter_data <- function(df, variables, nf = FALSE, missing = FALSE, adjust = FAL
|
||||
return(df)
|
||||
}
|
||||
|
||||
|
||||
main <- function() {
|
||||
lapply(names(args$experiments), function(exp_name) {
|
||||
exp <- args$experiments[[exp_name]]
|
||||
|
||||
Reference in New Issue
Block a user