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