|
@@ -1295,9 +1295,9 @@ main <- function() {
|
|
|
group_vars = c("OrfRep", "Gene", "num", "conc_num", "conc_num_factor")
|
|
|
)$df_with_stats
|
|
|
reference_results <- calculate_interaction_scores(df_reference_stats, max_conc, bg_stats, group_vars = c("OrfRep", "Gene", "num"))
|
|
|
- zscores_calculations_reference <- reference_results$calculations
|
|
|
- zscores_interactions_reference <- reference_results$interactions
|
|
|
- zscores_interactions_reference_joined <- reference_results$interactions_joined
|
|
|
+ zscore_calculations_reference <- reference_results$calculations
|
|
|
+ zscore_interactions_reference <- reference_results$interactions
|
|
|
+ zscore_interactions_reference_joined <- reference_results$interactions_joined
|
|
|
|
|
|
message("Calculating deletion strain(s) interactions scores")
|
|
|
df_deletion_stats <- calculate_summary_stats(
|
|
@@ -1306,97 +1306,97 @@ main <- function() {
|
|
|
group_vars = c("OrfRep", "Gene", "conc_num", "conc_num_factor")
|
|
|
)$df_with_stats
|
|
|
deletion_results <- calculate_interaction_scores(df_deletion_stats, max_conc, bg_stats, group_vars = c("OrfRep"))
|
|
|
- zscores_calculations <- deletion_results$calculations
|
|
|
- zscores_interactions <- deletion_results$interactions
|
|
|
- zscores_interactions_joined <- deletion_results$interactions_joined
|
|
|
+ zscore_calculations <- deletion_results$calculations
|
|
|
+ zscore_interactions <- deletion_results$interactions
|
|
|
+ zscore_interactions_joined <- deletion_results$interactions_joined
|
|
|
|
|
|
# Writing Z-Scores to file
|
|
|
- write.csv(zscores_calculations_reference, file = file.path(out_dir, "RF_ZScores_Calculations.csv"), row.names = FALSE)
|
|
|
- write.csv(zscores_calculations, file = file.path(out_dir, "ZScores_Calculations.csv"), row.names = FALSE)
|
|
|
- write.csv(zscores_interactions_reference, file = file.path(out_dir, "RF_ZScores_Interaction.csv"), row.names = FALSE)
|
|
|
- write.csv(zscores_interactions, file = file.path(out_dir, "ZScores_Interaction.csv"), row.names = FALSE)
|
|
|
+ write.csv(zscore_calculations_reference, file = file.path(out_dir, "zscore_calculations_reference.csv"), row.names = FALSE)
|
|
|
+ write.csv(zscore_calculations, file = file.path(out_dir, "zscore_calculations.csv"), row.names = FALSE)
|
|
|
+ write.csv(zscore_interactions_reference, file = file.path(out_dir, "zscore_interactions_reference.csv"), row.names = FALSE)
|
|
|
+ write.csv(zscore_interactions, file = file.path(out_dir, "zscore_interactions.csv"), row.names = FALSE)
|
|
|
|
|
|
# Create interaction plots
|
|
|
message("Generating reference interaction plots")
|
|
|
- reference_plot_configs <- generate_interaction_plot_configs(zscores_interactions_reference_joined, interaction_vars)
|
|
|
- generate_and_save_plots(out_dir, "RF_interactionPlots", reference_plot_configs, grid_layout = list(ncol = 4, nrow = 3))
|
|
|
+ reference_plot_configs <- generate_interaction_plot_configs(zscore_interactions_reference_joined, interaction_vars)
|
|
|
+ generate_and_save_plots(out_dir, "interaction_plots_reference", reference_plot_configs, grid_layout = list(ncol = 4, nrow = 3))
|
|
|
|
|
|
message("Generating deletion interaction plots")
|
|
|
- deletion_plot_configs <- generate_interaction_plot_configs(zscores_interactions_joined, interaction_vars)
|
|
|
- generate_and_save_plots(out_dir, "InteractionPlots", deletion_plot_configs, grid_layout = list(ncol = 4, nrow = 3))
|
|
|
+ deletion_plot_configs <- generate_interaction_plot_configs(zscore_interactions_joined, interaction_vars)
|
|
|
+ generate_and_save_plots(out_dir, "interaction_plots", deletion_plot_configs, grid_layout = list(ncol = 4, nrow = 3))
|
|
|
|
|
|
# Define conditions for enhancers and suppressors
|
|
|
# TODO Add to study config?
|
|
|
threshold <- 2
|
|
|
- enhancer_condition_L <- zscores_interactions$Avg_Zscore_L >= threshold
|
|
|
- suppressor_condition_L <- zscores_interactions$Avg_Zscore_L <= -threshold
|
|
|
- enhancer_condition_K <- zscores_interactions$Avg_Zscore_K >= threshold
|
|
|
- suppressor_condition_K <- zscores_interactions$Avg_Zscore_K <= -threshold
|
|
|
+ enhancer_condition_L <- zscore_interactions$Avg_Zscore_L >= threshold
|
|
|
+ suppressor_condition_L <- zscore_interactions$Avg_Zscore_L <= -threshold
|
|
|
+ enhancer_condition_K <- zscore_interactions$Avg_Zscore_K >= threshold
|
|
|
+ suppressor_condition_K <- zscore_interactions$Avg_Zscore_K <= -threshold
|
|
|
|
|
|
# Subset data
|
|
|
- enhancers_L <- zscores_interactions[enhancer_condition_L, ]
|
|
|
- suppressors_L <- zscores_interactions[suppressor_condition_L, ]
|
|
|
- enhancers_K <- zscores_interactions[enhancer_condition_K, ]
|
|
|
- suppressors_K <- zscores_interactions[suppressor_condition_K, ]
|
|
|
+ enhancers_L <- zscore_interactions[enhancer_condition_L, ]
|
|
|
+ suppressors_L <- zscore_interactions[suppressor_condition_L, ]
|
|
|
+ enhancers_K <- zscore_interactions[enhancer_condition_K, ]
|
|
|
+ suppressors_K <- zscore_interactions[suppressor_condition_K, ]
|
|
|
|
|
|
# Save enhancers and suppressors
|
|
|
message("Writing enhancer/suppressor csv files")
|
|
|
- write.csv(enhancers_L, file = file.path(out_dir, "ZScores_Interaction_Deletion_Enhancers_L.csv"), row.names = FALSE)
|
|
|
- write.csv(suppressors_L, file = file.path(out_dir, "ZScores_Interaction_Deletion_Suppressors_L.csv"), row.names = FALSE)
|
|
|
- write.csv(enhancers_K, file = file.path(out_dir, "ZScores_Interaction_Deletion_Enhancers_K.csv"), row.names = FALSE)
|
|
|
- write.csv(suppressors_K, file = file.path(out_dir, "ZScores_Interaction_Deletion_Suppressors_K.csv"), row.names = FALSE)
|
|
|
+ write.csv(enhancers_L, file = file.path(out_dir, "zscore_interactions_deletion_enhancers_L.csv"), row.names = FALSE)
|
|
|
+ write.csv(suppressors_L, file = file.path(out_dir, "zscore_interactions_deletion_suppressors_L.csv"), row.names = FALSE)
|
|
|
+ write.csv(enhancers_K, file = file.path(out_dir, "zscore_interactions_deletion_enhancers_K.csv"), row.names = FALSE)
|
|
|
+ write.csv(suppressors_K, file = file.path(out_dir, "zscore_interactions_deletion_suppressors_K.csv"), row.names = FALSE)
|
|
|
|
|
|
# Combine conditions for enhancers and suppressors
|
|
|
- enhancers_and_suppressors_L <- zscores_interactions[enhancer_condition_L | suppressor_condition_L, ]
|
|
|
- enhancers_and_suppressors_K <- zscores_interactions[enhancer_condition_K | suppressor_condition_K, ]
|
|
|
+ enhancers_and_suppressors_L <- zscore_interactions[enhancer_condition_L | suppressor_condition_L, ]
|
|
|
+ enhancers_and_suppressors_K <- zscore_interactions[enhancer_condition_K | suppressor_condition_K, ]
|
|
|
|
|
|
# Save combined enhancers and suppressors
|
|
|
write.csv(enhancers_and_suppressors_L,
|
|
|
- file = file.path(out_dir, "ZScores_Interaction_Deletion_Enhancers_and_Suppressors_L.csv"), row.names = FALSE)
|
|
|
+ file = file.path(out_dir, "zscore_interactions_deletion_enhancers_and_suppressors_L.csv"), row.names = FALSE)
|
|
|
write.csv(enhancers_and_suppressors_K,
|
|
|
- file = file.path(out_dir, "ZScores_Interaction_Deletion_Enhancers_and_Suppressors_K.csv"), row.names = FALSE)
|
|
|
+ file = file.path(out_dir, "zscore_interaction_deletion_enhancers_and_suppressors_K.csv"), row.names = FALSE)
|
|
|
|
|
|
# Handle linear model based enhancers and suppressors
|
|
|
lm_threshold <- 2
|
|
|
- enhancers_lm_L <- zscores_interactions[zscores_interactions$Z_lm_L >= lm_threshold, ]
|
|
|
- suppressors_lm_L <- zscores_interactions[zscores_interactions$Z_lm_L <= -lm_threshold, ]
|
|
|
- enhancers_lm_K <- zscores_interactions[zscores_interactions$Z_lm_K >= lm_threshold, ]
|
|
|
- suppressors_lm_K <- zscores_interactions[zscores_interactions$Z_lm_K <= -lm_threshold, ]
|
|
|
+ enhancers_lm_L <- zscore_interactions[zscore_interactions$Z_lm_L >= lm_threshold, ]
|
|
|
+ suppressors_lm_L <- zscore_interactions[zscore_interactions$Z_lm_L <= -lm_threshold, ]
|
|
|
+ enhancers_lm_K <- zscore_interactions[zscore_interactions$Z_lm_K >= lm_threshold, ]
|
|
|
+ suppressors_lm_K <- zscore_interactions[zscore_interactions$Z_lm_K <= -lm_threshold, ]
|
|
|
|
|
|
# Save linear model based enhancers and suppressors
|
|
|
message("Writing linear model enhancer/suppressor csv files")
|
|
|
write.csv(enhancers_lm_L,
|
|
|
- file = file.path(out_dir, "ZScores_Interaction_Deletion_Enhancers_L_lm.csv"), row.names = FALSE)
|
|
|
+ file = file.path(out_dir, "zscore_interactions_deletion_enhancers_lm_L.csv"), row.names = FALSE)
|
|
|
write.csv(suppressors_lm_L,
|
|
|
- file = file.path(out_dir, "ZScores_Interaction_Deletion_Suppressors_L_lm.csv"), row.names = FALSE)
|
|
|
+ file = file.path(out_dir, "zscore_interactions_deletion_suppressors_lm_L.csv"), row.names = FALSE)
|
|
|
write.csv(enhancers_lm_K,
|
|
|
- file = file.path(out_dir, "ZScores_Interaction_Deletion_Enhancers_K_lm.csv"), row.names = FALSE)
|
|
|
+ file = file.path(out_dir, "zscore_interactions_deletion_enhancers_lm_K.csv"), row.names = FALSE)
|
|
|
write.csv(suppressors_lm_K,
|
|
|
- file = file.path(out_dir, "ZScores_Interaction_Deletion_Suppressors_K_lm.csv"), row.names = FALSE)
|
|
|
+ file = file.path(out_dir, "zscore_interactions_deletion_suppressors_lm_K.csv"), row.names = FALSE)
|
|
|
|
|
|
message("Generating rank plots")
|
|
|
rank_plot_configs <- generate_rank_plot_configs(
|
|
|
- df = zscores_interactions_joined,
|
|
|
+ df = zscore_interactions_joined,
|
|
|
variables = interaction_vars,
|
|
|
is_lm = FALSE,
|
|
|
adjust = TRUE
|
|
|
)
|
|
|
- generate_and_save_plots(out_dir = out_dir, filename = "RankPlots",
|
|
|
+ generate_and_save_plots(out_dir = out_dir, filename = "rank_plots",
|
|
|
plot_configs = rank_plot_configs, grid_layout = list(ncol = 3, nrow = 2))
|
|
|
|
|
|
message("Generating ranked linear model plots")
|
|
|
rank_lm_plot_configs <- generate_rank_plot_configs(
|
|
|
- df = zscores_interactions_joined,
|
|
|
+ df = zscore_interactions_joined,
|
|
|
variables = interaction_vars,
|
|
|
is_lm = TRUE,
|
|
|
adjust = TRUE
|
|
|
)
|
|
|
- generate_and_save_plots(out_dir = out_dir, filename = "RankPlots_lm",
|
|
|
+ generate_and_save_plots(out_dir = out_dir, filename = "rank_plots_lm",
|
|
|
plot_configs = rank_lm_plot_configs, grid_layout = list(ncol = 3, nrow = 2))
|
|
|
|
|
|
message("Filtering and reranking plots")
|
|
|
# Formerly X_NArm
|
|
|
- zscores_interactions_filtered <- zscores_interactions_joined %>%
|
|
|
+ zscore_interactions_filtered <- zscore_interactions_joined %>%
|
|
|
filter(!is.na(Z_lm_L) & !is.na(Avg_Zscore_L)) %>%
|
|
|
mutate(
|
|
|
Overlap = case_when(
|
|
@@ -1418,7 +1418,7 @@ main <- function() {
|
|
|
|
|
|
message("Generating filtered ranked plots")
|
|
|
rank_plot_filtered_configs <- generate_rank_plot_configs(
|
|
|
- df = zscores_interactions_filtered,
|
|
|
+ df = zscore_interactions_filtered,
|
|
|
variables = interaction_vars,
|
|
|
is_lm = FALSE,
|
|
|
adjust = FALSE,
|
|
@@ -1433,7 +1433,7 @@ main <- function() {
|
|
|
|
|
|
message("Generating filtered ranked linear model plots")
|
|
|
rank_plot_lm_filtered_configs <- generate_rank_plot_configs(
|
|
|
- df = zscores_interactions_filtered,
|
|
|
+ df = zscore_interactions_filtered,
|
|
|
variables = interaction_vars,
|
|
|
is_lm = TRUE,
|
|
|
adjust = FALSE,
|
|
@@ -1441,15 +1441,15 @@ main <- function() {
|
|
|
)
|
|
|
generate_and_save_plots(
|
|
|
out_dir = out_dir,
|
|
|
- filename = "RankPlots_lm_na_rm",
|
|
|
+ filename = "rank_plots_lm_na_rm",
|
|
|
plot_configs = rank_plot_lm_filtered_configs,
|
|
|
grid_layout = list(ncol = 3, nrow = 2))
|
|
|
|
|
|
- message("Generating correlation plots")
|
|
|
- correlation_plot_configs <- generate_correlation_plot_configs(zscores_interactions_filtered)
|
|
|
+ message("Generating correlation curve parameter pair plots")
|
|
|
+ correlation_plot_configs <- generate_correlation_plot_configs(zscore_interactions_filtered)
|
|
|
generate_and_save_plots(
|
|
|
out_dir = out_dir,
|
|
|
- filename = "Correlation_CPPs",
|
|
|
+ filename = "correlation_cpps",
|
|
|
plot_configs = correlation_plot_configs,
|
|
|
grid_layout = list(ncol = 2, nrow = 2))
|
|
|
})
|