Add rank plot annotations
This commit is contained in:
@@ -180,7 +180,6 @@ calculate_summary_stats <- function(df, variables, group_vars = c("conc_num", "c
|
|||||||
return(list(summary_stats = summary_stats, df_with_stats = df_with_stats))
|
return(list(summary_stats = summary_stats, df_with_stats = df_with_stats))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
calculate_interaction_scores <- function(df, max_conc, variables, group_vars = c("OrfRep", "Gene", "num")) {
|
calculate_interaction_scores <- function(df, max_conc, variables, group_vars = c("OrfRep", "Gene", "num")) {
|
||||||
|
|
||||||
# Calculate total concentration variables
|
# Calculate total concentration variables
|
||||||
@@ -515,11 +514,11 @@ generate_interaction_plot_configs <- function(df, variables) {
|
|||||||
return(plot_configs)
|
return(plot_configs)
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_rank_plot_configs <- function(df, rank_var, zscore_var, label_prefix) {
|
generate_rank_plot_config <- function(df, rank_var, zscore_var, label_prefix) {
|
||||||
configs <- list()
|
configs <- list()
|
||||||
|
|
||||||
for (sd_band in c(1, 2, 3)) {
|
for (sd_band in c(1, 2, 3)) {
|
||||||
# Annotated version
|
# Annotated version (with text)
|
||||||
configs[[length(configs) + 1]] <- list(
|
configs[[length(configs) + 1]] <- list(
|
||||||
df = df,
|
df = df,
|
||||||
x_var = rank_var,
|
x_var = rank_var,
|
||||||
@@ -537,20 +536,33 @@ generate_rank_plot_configs <- function(df, rank_var, zscore_var, label_prefix) {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Non-annotated version
|
# Non-annotated version (_notext)
|
||||||
configs[[length(configs) + 1]] <- list(
|
configs[[length(configs) + 1]] <- list(
|
||||||
df = df,
|
df = df,
|
||||||
x_var = rank_var,
|
x_var = rank_var,
|
||||||
y_var = zscore_var,
|
y_var = zscore_var,
|
||||||
plot_type = "rank",
|
plot_type = "rank",
|
||||||
title = paste("Average Z score vs. Rank for", label_prefix, "above", sd_band, "SD"),
|
title = paste("Average Z score vs. Rank for", label_prefix, "above", sd_band, "SD"),
|
||||||
sd_band = sd_band
|
sd_band = sd_band,
|
||||||
|
enhancer_label = NULL, # Remove annotations for _notext
|
||||||
|
suppressor_label = NULL # Remove annotations for _notext
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return(configs)
|
return(configs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Generate all rank plot configurations for L and K (annotated and _notext)
|
||||||
|
rank_plot_config <- c(
|
||||||
|
create_rank_plot_config(zscores_interactions_adjusted, "L_Rank", "Avg_Zscore_L", "L"),
|
||||||
|
create_rank_plot_config(zscores_interactions_adjusted, "K_Rank", "Avg_Zscore_K", "K")
|
||||||
|
)
|
||||||
|
|
||||||
|
# Generate and save rank plots
|
||||||
|
generate_and_save_plots(output_dir = out_dir, file_name = "RankPlots",
|
||||||
|
plot_configs = rank_plot_config, grid_layout = list(ncol = 3, nrow = 2))
|
||||||
|
|
||||||
|
|
||||||
generate_correlation_plot_configs <- function(df, lm_list, lm_summaries) {
|
generate_correlation_plot_configs <- function(df, lm_list, lm_summaries) {
|
||||||
lapply(seq_along(lm_list), function(i) {
|
lapply(seq_along(lm_list), function(i) {
|
||||||
r_squared <- round(lm_summaries[[i]]$r.squared, 3)
|
r_squared <- round(lm_summaries[[i]]$r.squared, 3)
|
||||||
|
|||||||
Reference in New Issue
Block a user