Preserve conc cols for later
This commit is contained in:
@@ -193,8 +193,7 @@ calculate_summary_stats <- function(df, variables, group_vars) {
|
||||
return(list(summary_stats = summary_stats, df_with_stats = df_joined))
|
||||
}
|
||||
|
||||
calculate_interaction_scores <- function(df, max_conc, variables = c("L", "K", "r", "AUC"),
|
||||
group_vars = c("OrfRep", "Gene", "num")) {
|
||||
calculate_interaction_scores <- function(df, max_conc, variables = c("L", "K", "r", "AUC")) {
|
||||
|
||||
# Calculate total concentration variables
|
||||
total_conc_num <- length(unique(df$conc_num))
|
||||
@@ -221,7 +220,7 @@ calculate_interaction_scores <- function(df, max_conc, variables = c("L", "K", "
|
||||
)$df_with_stats
|
||||
|
||||
calculations <- calculations %>%
|
||||
group_by(across(all_of(group_vars))) %>%
|
||||
group_by(OrfRep, Gene, num) %>%
|
||||
mutate(
|
||||
NG = sum(NG, na.rm = TRUE),
|
||||
DB = sum(DB, na.rm = TRUE),
|
||||
@@ -303,12 +302,8 @@ calculate_interaction_scores <- function(df, max_conc, variables = c("L", "K", "
|
||||
|
||||
# Summarize some of the stats
|
||||
interactions <- calculations %>%
|
||||
group_by(across(all_of(group_vars))) %>%
|
||||
group_by(OrfRep, Gene, num) %>%
|
||||
mutate(
|
||||
OrfRep = first(OrfRep),
|
||||
Gene = first(Gene),
|
||||
num = first(num),
|
||||
|
||||
# Calculate raw shifts
|
||||
Raw_Shift_L = first(Raw_Shift_L),
|
||||
Raw_Shift_K = first(Raw_Shift_K),
|
||||
@@ -355,7 +350,7 @@ calculate_interaction_scores <- function(df, max_conc, variables = c("L", "K", "
|
||||
|
||||
interactions <- interactions %>%
|
||||
select(
|
||||
"OrfRep", "Gene", "num", "NG", "DB", "SM",
|
||||
"OrfRep", "Gene", "conc_num", "conc_num_factor", "num", "NG", "DB", "SM",
|
||||
"Raw_Shift_L", "Raw_Shift_K", "Raw_Shift_r", "Raw_Shift_AUC",
|
||||
"Z_Shift_L", "Z_Shift_K", "Z_Shift_r", "Z_Shift_AUC",
|
||||
"Sum_Z_Score_L", "Sum_Z_Score_K", "Sum_Z_Score_r", "Sum_Z_Score_AUC",
|
||||
@@ -364,21 +359,17 @@ calculate_interaction_scores <- function(df, max_conc, variables = c("L", "K", "
|
||||
"R_Squared_L", "R_Squared_K", "R_Squared_r", "R_Squared_AUC",
|
||||
"Z_lm_L", "Z_lm_K", "Z_lm_r", "Z_lm_AUC")
|
||||
|
||||
# cleaned_df <- df %>%
|
||||
# select(-any_of(setdiff(intersect(names(df), names(calculations)), group_vars)))
|
||||
|
||||
# calculations_joined <- left_join(cleaned_df, calculations, by = c("OrfRep", "Gene", "num", "conc_num", "conc_num_factor"))
|
||||
|
||||
cleaned_df <- df %>%
|
||||
select(-any_of(setdiff(intersect(names(df), names(interactions)), group_vars)))
|
||||
select(-any_of(
|
||||
setdiff(intersect(names(df), names(interactions)),
|
||||
c("OrfRep", "Gene", "num", "conc_num", "conc_num_factor"))))
|
||||
|
||||
interactions_joined <- left_join(cleaned_df, interactions, by = c("OrfRep", "Gene", "num", "conc_num", "conc_num_factor"))
|
||||
|
||||
return(list(
|
||||
calculations = calculations,
|
||||
interactions = interactions,
|
||||
interactions_joined = interactions_joined
|
||||
))
|
||||
interactions_joined = interactions_joined))
|
||||
}
|
||||
|
||||
generate_and_save_plots <- function(out_dir, filename, plot_configs, grid_layout = NULL) {
|
||||
|
||||
Reference in New Issue
Block a user