Fix l_outside to match l_within df logic
This commit is contained in:
@@ -298,6 +298,7 @@ process_strains <- function(df) {
|
||||
calculate_interaction_scores <- function(df, max_conc, variables, group_vars = c("OrfRep", "Gene", "num")) {
|
||||
|
||||
# Pull the background means
|
||||
print("Calculating background means")
|
||||
l_mean_bg <- df %>% filter(conc_num_factor == 0) %>% pull(L_mean)
|
||||
k_mean_bg <- df %>% filter(conc_num_factor == 0) %>% pull(K_mean)
|
||||
r_mean_bg <- df %>% filter(conc_num_factor == 0) %>% pull(r_mean)
|
||||
@@ -576,32 +577,26 @@ main <- function() {
|
||||
outside_2sd_k <- stats_joined %>%
|
||||
filter(K < (K_mean - 2 * K_sd) | K > (K_mean + 2 * K_sd))
|
||||
|
||||
# Calculate summary statistics for L within and outside 2SD of K
|
||||
message("Calculating summary statistics for L within 2SD of K")
|
||||
|
||||
l_within_2sd_k <- calculate_summary_stats(within_2sd_k, "L", group_vars = c("conc_num", "conc_num_factor"))
|
||||
|
||||
# Remove existing calculated summary statistics and add the new ones
|
||||
cols_to_remove <- names(l_within_2sd_k)
|
||||
cols_to_keep <- c("conc_num", "conc_num_factor")
|
||||
within_2sd_k_clean <- within_2sd_k %>%
|
||||
select(-all_of(setdiff(cols_to_remove, cols_to_keep)))
|
||||
l_within_2sd_k_joined <- within_2sd_k_clean %>%
|
||||
left_join(l_within_2sd_k, by = c("conc_num", "conc_num_factor"))
|
||||
|
||||
# print("within_2sd_k")
|
||||
# print(head(within_2sd_k))
|
||||
# print("l_within_2sd_k")
|
||||
# print(head(l_within_2sd_k))
|
||||
# print("l_within_2sd_k_joined")
|
||||
# print(head(l_within_2sd_k_joined))
|
||||
|
||||
write.csv(l_within_2sd_k,
|
||||
file = file.path(out_dir_qc, "Max_Observed_L_Vals_for_spots_within_2sd_k.csv"),
|
||||
row.names = FALSE)
|
||||
|
||||
message("Calculating summary statistics for for L outside 2SD of K")
|
||||
l_outside_2sd_k <- calculate_summary_stats(outside_2sd_k, "L", group_vars = c("conc_num", "conc_num_factor"))
|
||||
l_outside_2sd_k_joined <- merge(outside_2sd_k, l_outside_2sd_k, by = c("conc_num", "conc_num_factor"), all.x = TRUE)
|
||||
cols_to_remove <- names(l_outside_2sd_k)
|
||||
cols_to_keep <- c("conc_num", "conc_num_factor")
|
||||
outside_2sd_k_clean <- outside_2sd_k %>%
|
||||
select(-all_of(setdiff(cols_to_remove, cols_to_keep)))
|
||||
l_outside_2sd_k_joined <- outside_2sd_k_clean %>%
|
||||
left_join(l_outside_2sd_k, by = c("conc_num", "conc_num_factor"))
|
||||
write.csv(l_outside_2sd_k,
|
||||
file = file.path(out_dir, "Max_Observed_L_Vals_for_spots_outside_2sd_k.csv"),
|
||||
row.names = FALSE)
|
||||
@@ -634,12 +629,12 @@ main <- function() {
|
||||
|
||||
# Filter reference and deletion strains
|
||||
# Formerly X2_RF (reference strain)
|
||||
df_reference <- df_na %>%
|
||||
df_reference <- stats_joined %>%
|
||||
filter(OrfRep == strain) %>%
|
||||
mutate(SM = 0)
|
||||
|
||||
# Formerly X2 (deletion strains)
|
||||
df_deletion <- df_na %>%
|
||||
df_deletion <- stats_joined %>%
|
||||
filter(OrfRep != strain) %>%
|
||||
mutate(SM = 0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user