From 814cec8ca278b2b01ca967696235e0082efdb991 Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Sat, 31 Aug 2024 16:40:01 -0400 Subject: [PATCH] Auto-commit: apps/r/calculate_interaction_zscores5.R --- .../apps/r/calculate_interaction_zscores5.R | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/workflow/apps/r/calculate_interaction_zscores5.R b/workflow/apps/r/calculate_interaction_zscores5.R index d0b0df08..9d67bd20 100644 --- a/workflow/apps/r/calculate_interaction_zscores5.R +++ b/workflow/apps/r/calculate_interaction_zscores5.R @@ -516,6 +516,10 @@ main <- function() { zscores_interactions_reference <- reference_results$zscores_interactions zscores_calculations <- deletion_results$zscores_calculations zscores_interactions <- deletion_results$zscores_interactions + + zscores_interactions <- zscores_interactions %>% + arrange(desc(Z_lm_L)) %>% + arrange(desc(NG)) 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) @@ -566,10 +570,6 @@ main <- function() { write.csv(suppressors_lm_K, file = file.path(out_dir, "ZScores_Interaction_DeletionSuppressors_K_lm.csv"), row.names = FALSE) - interaction_scores_deletion <- interaction_scores_deletion %>% - arrange(desc(Z_lm_L)) %>% - arrange(desc(NG)) - # Generate plots for interaction scores }) }) @@ -861,45 +861,45 @@ for (s in background_strains) { # ) # } - print("Pass Int Calculation loop") + # print("Pass Int Calculation loop") - # Order the interaction scores by Z_lm_L and NG - interaction_scores_deletion <- interaction_scores_deletion %>% - arrange(desc(Z_lm_L)) %>% - arrange(desc(NG)) + # # Order the interaction scores by Z_lm_L and NG + # interaction_scores_deletion <- interaction_scores_deletion %>% + # arrange(desc(Z_lm_L)) %>% + # arrange(desc(NG)) # Save the interaction scores and filtered sets for enhancers and suppressors - output_files <- list( - "ZScores_Interaction.csv" = interaction_scores_deletion, - "ZScores_Interaction_DeletionEnhancers_L.csv" = filter(interaction_scores_deletion, Avg_Zscore_L >= 2), - "ZScores_Interaction_DeletionEnhancers_K.csv" = filter(interaction_scores_deletion, Avg_Zscore_K <= -2), - "ZScores_Interaction_DeletionSuppressors_L.csv" = filter(interaction_scores_deletion, Avg_Zscore_L <= -2), - "ZScores_Interaction_DeletionSuppressors_K.csv" = filter(interaction_scores_deletion, Avg_Zscore_K >= 2), - "ZScores_Interaction_DeletionEnhancers_and_Suppressors_L.csv" = filter(interaction_scores_deletion, Avg_Zscore_L >= 2 | Avg_Zscore_L <= -2), - "ZScores_Interaction_DeletionEnhancers_and_Suppressors_K.csv" = filter(interaction_scores_deletion, Avg_Zscore_K >= 2 | Avg_Zscore_K <= -2), - "ZScores_Interaction_Suppressors_and_lm_Enhancers_L.csv" = filter(interaction_scores_deletion, Z_lm_L >= 2 & Avg_Zscore_L <= -2), - "ZScores_Interaction_Enhancers_and_lm_Suppressors_L.csv" = filter(interaction_scores_deletion, Z_lm_L <= -2 & Avg_Zscore_L >= 2), - "ZScores_Interaction_Suppressors_and_lm_Enhancers_K.csv" = filter(interaction_scores_deletion, Z_lm_K <= -2 & Avg_Zscore_K >= 2), - "ZScores_Interaction_Enhancers_and_lm_Suppressors_K.csv" = filter(interaction_scores_deletion, Z_lm_K >= 2 & Avg_Zscore_K <= -2) - ) + # output_files <- list( + # "ZScores_Interaction.csv" = interaction_scores_deletion, + # "ZScores_Interaction_DeletionEnhancers_L.csv" = filter(interaction_scores_deletion, Avg_Zscore_L >= 2), + # "ZScores_Interaction_DeletionEnhancers_K.csv" = filter(interaction_scores_deletion, Avg_Zscore_K <= -2), + # "ZScores_Interaction_DeletionSuppressors_L.csv" = filter(interaction_scores_deletion, Avg_Zscore_L <= -2), + # "ZScores_Interaction_DeletionSuppressors_K.csv" = filter(interaction_scores_deletion, Avg_Zscore_K >= 2), + # "ZScores_Interaction_DeletionEnhancers_and_Suppressors_L.csv" = filter(interaction_scores_deletion, Avg_Zscore_L >= 2 | Avg_Zscore_L <= -2), + # "ZScores_Interaction_DeletionEnhancers_and_Suppressors_K.csv" = filter(interaction_scores_deletion, Avg_Zscore_K >= 2 | Avg_Zscore_K <= -2), + # "ZScores_Interaction_Suppressors_and_lm_Enhancers_L.csv" = filter(interaction_scores_deletion, Z_lm_L >= 2 & Avg_Zscore_L <= -2), + # "ZScores_Interaction_Enhancers_and_lm_Suppressors_L.csv" = filter(interaction_scores_deletion, Z_lm_L <= -2 & Avg_Zscore_L >= 2), + # "ZScores_Interaction_Suppressors_and_lm_Enhancers_K.csv" = filter(interaction_scores_deletion, Z_lm_K <= -2 & Avg_Zscore_K >= 2), + # "ZScores_Interaction_Enhancers_and_lm_Suppressors_K.csv" = filter(interaction_scores_deletion, Z_lm_K >= 2 & Avg_Zscore_K <= -2) + # ) - for (file_name in names(output_files)) { - write.csv(output_files[[file_name]], file = file.path(output_dir, file_name), row.names = FALSE) - } + # for (file_name in names(output_files)) { + # write.csv(output_files[[file_name]], file = file.path(output_dir, file_name), row.names = FALSE) + # } - # Further filtering for linear regression enhancers and suppressors - output_files_lm <- list( - "ZScores_Interaction_DeletionEnhancers_L_lm.csv" = filter(interaction_scores_deletion, Z_lm_L >= 2), - "ZScores_Interaction_DeletionEnhancers_K_lm.csv" = filter(interaction_scores_deletion, Z_lm_K <= -2), - "ZScores_Interaction_DeletionSuppressors_L_lm.csv" = filter(interaction_scores_deletion, Z_lm_L <= -2), - "ZScores_Interaction_DeletionSuppressors_K_lm.csv" = filter(interaction_scores_deletion, Z_lm_K >= 2), - "ZScores_Interaction_DeletionEnhancers_and_Suppressors_L_lm.csv" = filter(interaction_scores_deletion, Z_lm_L >= 2 | Z_lm_L <= -2), - "ZScores_Interaction_DeletionEnhancers_and_Suppressors_K_lm.csv" = filter(interaction_scores_deletion, Z_lm_K >= 2 | Z_lm_K <= -2) - ) + # # Further filtering for linear regression enhancers and suppressors + # output_files_lm <- list( + # "ZScores_Interaction_DeletionEnhancers_L_lm.csv" = filter(interaction_scores_deletion, Z_lm_L >= 2), + # "ZScores_Interaction_DeletionEnhancers_K_lm.csv" = filter(interaction_scores_deletion, Z_lm_K <= -2), + # "ZScores_Interaction_DeletionSuppressors_L_lm.csv" = filter(interaction_scores_deletion, Z_lm_L <= -2), + # "ZScores_Interaction_DeletionSuppressors_K_lm.csv" = filter(interaction_scores_deletion, Z_lm_K >= 2), + # "ZScores_Interaction_DeletionEnhancers_and_Suppressors_L_lm.csv" = filter(interaction_scores_deletion, Z_lm_L >= 2 | Z_lm_L <= -2), + # "ZScores_Interaction_DeletionEnhancers_and_Suppressors_K_lm.csv" = filter(interaction_scores_deletion, Z_lm_K >= 2 | Z_lm_K <= -2) + # ) - for (file_name in names(output_files_lm)) { - write.csv(output_files_lm[[file_name]], file = file.path(output_dir, file_name), row.names = FALSE) - } + # for (file_name in names(output_files_lm)) { + # write.csv(output_files_lm[[file_name]], file = file.path(output_dir, file_name), row.names = FALSE) + # } # Loop through each gene to generate plots