|
@@ -203,20 +203,7 @@ calculate_interaction_scores <- function(df, max_conc, variables, group_vars = c
|
|
AUC = df %>% filter(conc_num_factor == 0) %>% pull(sd_AUC) %>% first()
|
|
AUC = df %>% filter(conc_num_factor == 0) %>% pull(sd_AUC) %>% first()
|
|
)
|
|
)
|
|
|
|
|
|
- # Grab these values from the original df before mutating the new stats
|
|
|
|
stats <- df %>%
|
|
stats <- df %>%
|
|
- mutate(
|
|
|
|
- WT_L = mean_L,
|
|
|
|
- WT_K = mean_K,
|
|
|
|
- WT_r = mean_r,
|
|
|
|
- WT_AUC = mean_AUC,
|
|
|
|
- WT_sd_L = sd_L,
|
|
|
|
- WT_sd_K = sd_K,
|
|
|
|
- WT_sd_r = sd_r,
|
|
|
|
- WT_sd_AUC = sd_AUC
|
|
|
|
- )
|
|
|
|
-
|
|
|
|
- stats <- stats %>%
|
|
|
|
group_by(OrfRep, Gene, num, conc_num, conc_num_factor) %>%
|
|
group_by(OrfRep, Gene, num, conc_num, conc_num_factor) %>%
|
|
summarise(
|
|
summarise(
|
|
N = sum(!is.na(L)),
|
|
N = sum(!is.na(L)),
|
|
@@ -233,9 +220,21 @@ calculate_interaction_scores <- function(df, max_conc, variables, group_vars = c
|
|
), .names = "{.fn}_{.col}")
|
|
), .names = "{.fn}_{.col}")
|
|
)
|
|
)
|
|
|
|
|
|
- stats <- stats %>%
|
|
|
|
|
|
+ stats <- df %>%
|
|
group_by(OrfRep, Gene, num) %>%
|
|
group_by(OrfRep, Gene, num) %>%
|
|
mutate(
|
|
mutate(
|
|
|
|
+ WT_L = mean_L,
|
|
|
|
+ WT_K = mean_K,
|
|
|
|
+ WT_r = mean_r,
|
|
|
|
+ WT_AUC = mean_AUC,
|
|
|
|
+ WT_sd_L = sd_L,
|
|
|
|
+ WT_sd_K = sd_K,
|
|
|
|
+ WT_sd_r = sd_r,
|
|
|
|
+ WT_sd_AUC = sd_AUC
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ stats <- stats %>%
|
|
|
|
+ mutate(
|
|
Raw_Shift_L = first(mean_L) - bg_means$L,
|
|
Raw_Shift_L = first(mean_L) - bg_means$L,
|
|
Raw_Shift_K = first(mean_K) - bg_means$K,
|
|
Raw_Shift_K = first(mean_K) - bg_means$K,
|
|
Raw_Shift_r = first(mean_r) - bg_means$r,
|
|
Raw_Shift_r = first(mean_r) - bg_means$r,
|
|
@@ -343,7 +342,7 @@ calculate_interaction_scores <- function(df, max_conc, variables, group_vars = c
|
|
"Zscore_L", "Zscore_K", "Zscore_r", "Zscore_AUC",
|
|
"Zscore_L", "Zscore_K", "Zscore_r", "Zscore_AUC",
|
|
"NG", "SM", "DB")
|
|
"NG", "SM", "DB")
|
|
|
|
|
|
- df <- df %>% select(-any_of(setdiff(names(calculations), OrfRep, Gene, num, conc_num, conc_num_factor)))
|
|
|
|
|
|
+ df <- df %>% select(-any_of(setdiff(names(calculations), c("OrfRep", "Gene", "num", "conc_num", "conc_num_factor"))))
|
|
df <- left_join(df, calculations, by = c("OrfRep", "Gene", "num", "conc_num", "conc_num_factor"))
|
|
df <- left_join(df, calculations, by = c("OrfRep", "Gene", "num", "conc_num", "conc_num_factor"))
|
|
# df <- df %>% select(-any_of(setdiff(names(interactions), group_vars)))
|
|
# df <- df %>% select(-any_of(setdiff(names(interactions), group_vars)))
|
|
# df <- left_join(df, interactions, by = group_vars)
|
|
# df <- left_join(df, interactions, by = group_vars)
|
|
@@ -412,24 +411,20 @@ generate_and_save_plots <- function(output_dir, file_name, plot_configs, grid_la
|
|
saveWidget(combined_plot, file = file.path(output_dir, paste0(file_name, ".html")), selfcontained = TRUE)
|
|
saveWidget(combined_plot, file = file.path(output_dir, paste0(file_name, ".html")), selfcontained = TRUE)
|
|
}
|
|
}
|
|
|
|
|
|
-generate_scatter_plot <- function(plot, config, interactive = FALSE) {
|
|
|
|
|
|
+generate_scatter_plot <- function(plot, config) {
|
|
|
|
|
|
- # Add the interactive `text` aesthetic if `interactive` is TRUE
|
|
|
|
- if (interactive) {
|
|
|
|
- plot <- if (!is.null(config$delta_bg_point) && config$delta_bg_point) {
|
|
|
|
|
|
+ # Add the interactive text aesthetics to the scatter points
|
|
|
|
+ plot <-
|
|
|
|
+ if (!is.null(config$delta_bg_point) && config$delta_bg_point) {
|
|
plot + geom_point(aes(text = paste("ORF:", OrfRep, "Gene:", Gene, "delta_bg:", delta_bg)),
|
|
plot + geom_point(aes(text = paste("ORF:", OrfRep, "Gene:", Gene, "delta_bg:", delta_bg)),
|
|
shape = config$shape %||% 3, size = config$size %||% 0.2)
|
|
shape = config$shape %||% 3, size = config$size %||% 0.2)
|
|
} else if (!is.null(config$gene_point) && config$gene_point) {
|
|
} else if (!is.null(config$gene_point) && config$gene_point) {
|
|
plot + geom_point(aes(text = paste("ORF:", OrfRep, "Gene:", Gene)),
|
|
plot + geom_point(aes(text = paste("ORF:", OrfRep, "Gene:", Gene)),
|
|
shape = config$shape %||% 3, size = config$size %||% 0.2, position = "jitter")
|
|
shape = config$shape %||% 3, size = config$size %||% 0.2, position = "jitter")
|
|
} else {
|
|
} else {
|
|
- plot + geom_point(shape = config$shape %||% 3, size = config$size %||% 0.2)
|
|
|
|
|
|
+ plot + geom_point(shape = config$shape %||% 3, size = config$size %||% 0.2,
|
|
|
|
+ position = config$position %||% "identity")
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- # For non-interactive plots, just add `geom_point`
|
|
|
|
- plot <- plot + geom_point(shape = config$shape %||% 3, size = config$size %||% 0.2,
|
|
|
|
- position = if (!is.null(config$position) && config$position == "jitter") "jitter" else "identity")
|
|
|
|
- }
|
|
|
|
|
|
|
|
# Add smooth line if specified
|
|
# Add smooth line if specified
|
|
if (!is.null(config$add_smooth) && config$add_smooth) {
|
|
if (!is.null(config$add_smooth) && config$add_smooth) {
|