|
@@ -514,9 +514,12 @@ generate_interaction_plot_configs <- function(df, variables) {
|
|
|
return(plot_configs)
|
|
|
}
|
|
|
|
|
|
-generate_rank_plot_config <- function(df, rank_var, zscore_var, label_prefix) {
|
|
|
+generate_rank_plot_configs <- function(df, rank_var, zscore_var, label_prefix, is_lm = FALSE) {
|
|
|
configs <- list()
|
|
|
|
|
|
+ # Adjust titles for _lm plots if is_lm is TRUE
|
|
|
+ plot_title_prefix <- if (is_lm) "Interaction Z score vs. Rank for" else "Average Z score vs. Rank for"
|
|
|
+
|
|
|
for (sd_band in c(1, 2, 3)) {
|
|
|
# Annotated version (with text)
|
|
|
configs[[length(configs) + 1]] <- list(
|
|
@@ -524,7 +527,7 @@ generate_rank_plot_config <- function(df, rank_var, zscore_var, label_prefix) {
|
|
|
x_var = rank_var,
|
|
|
y_var = zscore_var,
|
|
|
plot_type = "rank",
|
|
|
- title = paste("Average Z score vs. Rank for", label_prefix, "above", sd_band, "SD"),
|
|
|
+ title = paste(plot_title_prefix, label_prefix, "above", sd_band, "SD"),
|
|
|
sd_band = sd_band,
|
|
|
enhancer_label = list(
|
|
|
x = nrow(df) / 2, y = 10,
|
|
@@ -542,16 +545,17 @@ generate_rank_plot_config <- function(df, rank_var, zscore_var, label_prefix) {
|
|
|
x_var = rank_var,
|
|
|
y_var = zscore_var,
|
|
|
plot_type = "rank",
|
|
|
- title = paste("Average Z score vs. Rank for", label_prefix, "above", sd_band, "SD"),
|
|
|
+ title = paste(plot_title_prefix, label_prefix, "above", sd_band, "SD"),
|
|
|
sd_band = sd_band,
|
|
|
- enhancer_label = NULL, # Remove annotations for _notext
|
|
|
- suppressor_label = NULL # Remove annotations for _notext
|
|
|
+ enhancer_label = NULL, # No annotations for _notext
|
|
|
+ suppressor_label = NULL # No annotations for _notext
|
|
|
)
|
|
|
}
|
|
|
|
|
|
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"),
|
|
@@ -928,16 +932,23 @@ main <- function() {
|
|
|
|
|
|
zscores_interactions_adjusted <- adjust_missing_and_rank(zscores_interactions)
|
|
|
|
|
|
- # Generate all rank plot configurations for L and K
|
|
|
rank_plot_configs <- c(
|
|
|
generate_rank_plot_configs(zscores_interactions_adjusted, "Rank_L", "Avg_Zscore_L", "L"),
|
|
|
generate_rank_plot_configs(zscores_interactions_adjusted, "Rank_K", "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))
|
|
|
|
|
|
+ rank_lm_plot_config <- c(
|
|
|
+ generate_rank_lm_plot_configs(zscores_interactions_adjusted, "Rank_lm_L", "Z_lm_L", "L"),
|
|
|
+ generate_rank_lm_plot_configs(zscores_interactions_adjusted, "Rank_lm_K", "Z_lm_K", "K")
|
|
|
+ )
|
|
|
+ generate_and_save_plots(output_dir = out_dir, file_name = "RankPlots_lm",
|
|
|
+ plot_configs = rank_lm_plot_config, grid_layout = list(ncol = 3, nrow = 2))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
# # Correlation plots
|
|
|
# lm_list <- list(
|
|
|
# lm(Z_lm_K ~ Z_lm_L, data = zscores_interactions_filtered),
|