Fix rank vars names
This commit is contained in:
@@ -727,7 +727,7 @@ generate_interaction_plot_configs <- function(df, variables) {
|
|||||||
# Box plot config
|
# Box plot config
|
||||||
configs[[length(configs) + 1]] <- modifyList(plot_settings, list(
|
configs[[length(configs) + 1]] <- modifyList(plot_settings, list(
|
||||||
plot_type = "box",
|
plot_type = "box",
|
||||||
title = sprintf("%s %s (Boxplot)", df_filtered$OrfRep[1], df_filtered$Gene[1]),
|
title = sprintf("%s %s (box plot)", df_filtered$OrfRep[1], df_filtered$Gene[1]),
|
||||||
error_bar = FALSE
|
error_bar = FALSE
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@@ -746,11 +746,11 @@ generate_rank_plot_configs <- function(df_filtered, variables, is_lm = FALSE) {
|
|||||||
for (sd_band in sd_bands) {
|
for (sd_band in sd_bands) {
|
||||||
# Determine columns based on whether it's lm or not
|
# Determine columns based on whether it's lm or not
|
||||||
if (is_lm) {
|
if (is_lm) {
|
||||||
rank_var <- paste0(variable, "_Rank_lm")
|
rank_var <- paste0("Rank_lm_", variable)
|
||||||
zscore_var <- paste0("Z_lm_", variable)
|
zscore_var <- paste0("Z_lm_", variable)
|
||||||
y_label <- paste("Int Z score", variable)
|
y_label <- paste("Int Z score", variable)
|
||||||
} else {
|
} else {
|
||||||
rank_var <- paste0(variable, "_Rank")
|
rank_var <- paste0("Rank_", variable)
|
||||||
zscore_var <- paste0("Avg_Zscore_", variable)
|
zscore_var <- paste0("Avg_Zscore_", variable)
|
||||||
y_label <- paste("Avg Z score", variable)
|
y_label <- paste("Avg Z score", variable)
|
||||||
}
|
}
|
||||||
@@ -819,19 +819,27 @@ generate_rank_plot_configs <- function(df_filtered, variables, is_lm = FALSE) {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
x_var <- paste0(variable, "_Rank")
|
x_var <- paste0("Rank", variable)
|
||||||
y_var <- paste0(variable, "_Rank_lm")
|
y_var <- paste0("Rank_lm_", variable)
|
||||||
title_suffix <- paste("Rank Avg Zscore vs lm", variable)
|
title_suffix <- paste("Rank Avg Zscore vs lm", variable)
|
||||||
rectangles <- NULL
|
rectangles <- NULL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print(df_filtered %>% select(all_of(c(x_var, y_var))))
|
||||||
|
|
||||||
|
# Check if there is sufficient variation
|
||||||
|
if (length(unique(df_filtered[[x_var]])) < 2 || length(unique(df_filtered[[y_var]])) < 2) {
|
||||||
|
message("Not enough variation in ", x_var, " or ", y_var, " to fit linear model. Skipping.")
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
# Fit linear model
|
# Fit linear model
|
||||||
lm_fit <- lm(df_filtered[[y_var]] ~ df_filtered[[x_var]], data = df_filtered)
|
lm_fit <- lm(df_filtered[[y_var]] ~ df_filtered[[x_var]], data = df_filtered)
|
||||||
|
|
||||||
# Check for perfect fit
|
# # Check for perfect fit
|
||||||
if (summary(lm_fit)$sigma == 0) {
|
# if (summary(lm_fit)$sigma == 0) {
|
||||||
next # Skip this iteration if the fit is perfect
|
# next # Skip this iteration if the fit is perfect
|
||||||
}
|
# }
|
||||||
|
|
||||||
r_squared <- summary(lm_fit)$r.squared
|
r_squared <- summary(lm_fit)$r.squared
|
||||||
|
|
||||||
@@ -1158,7 +1166,7 @@ main <- function() {
|
|||||||
df_after = df_na_filtered_stats,
|
df_after = df_na_filtered_stats,
|
||||||
)
|
)
|
||||||
|
|
||||||
plate_analysis_box_plot_configs <- generate_plate_analysis_plot_configs(
|
plate_analysis_boxplot_configs <- generate_plate_analysis_plot_configs(
|
||||||
variables = summary_vars,
|
variables = summary_vars,
|
||||||
df_before = df_filtered_stats,
|
df_before = df_filtered_stats,
|
||||||
df_after = df_na_filtered_stats,
|
df_after = df_na_filtered_stats,
|
||||||
@@ -1206,16 +1214,16 @@ main <- function() {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
message("Generating quality control plots")
|
# message("Generating quality control plots")
|
||||||
generate_and_save_plots(out_dir_qc, "L_vs_K_before_quality_control", l_vs_k_plots)
|
# generate_and_save_plots(out_dir_qc, "L_vs_K_before_quality_control", l_vs_k_plots)
|
||||||
generate_and_save_plots(out_dir_qc, "frequency_delta_background", frequency_delta_bg_plots)
|
# generate_and_save_plots(out_dir_qc, "frequency_delta_background", frequency_delta_bg_plots)
|
||||||
generate_and_save_plots(out_dir_qc, "L_vs_K_above_threshold", above_threshold_plots)
|
# generate_and_save_plots(out_dir_qc, "L_vs_K_above_threshold", above_threshold_plots)
|
||||||
generate_and_save_plots(out_dir_qc, "plate_analysis", plate_analysis_plot_configs)
|
# generate_and_save_plots(out_dir_qc, "plate_analysis", plate_analysis_plot_configs)
|
||||||
generate_and_save_plots(out_dir_qc, "plate_analysis_boxplots", plate_analysis_boxplot_configs)
|
# generate_and_save_plots(out_dir_qc, "plate_analysis_boxplots", plate_analysis_boxplot_configs)
|
||||||
generate_and_save_plots(out_dir_qc, "plate_analysis_no_zeros", plate_analysis_no_zeros_plot_configs)
|
# generate_and_save_plots(out_dir_qc, "plate_analysis_no_zeros", plate_analysis_no_zeros_plot_configs)
|
||||||
generate_and_save_plots(out_dir_qc, "plate_analysis_no_zeros_boxplots", plate_analysis_no_zeros_boxplot_configs)
|
# generate_and_save_plots(out_dir_qc, "plate_analysis_no_zeros_boxplots", plate_analysis_no_zeros_boxplot_configs)
|
||||||
generate_and_save_plots(out_dir_qc, "L_vs_K_for_strains_2SD_outside_mean_K", l_outside_2sd_k_plots)
|
# generate_and_save_plots(out_dir_qc, "L_vs_K_for_strains_2SD_outside_mean_K", l_outside_2sd_k_plots)
|
||||||
generate_and_save_plots(out_dir_qc, "delta_background_vs_K_for_strains_2sd_outside_mean_K", delta_bg_outside_2sd_k_plots)
|
# generate_and_save_plots(out_dir_qc, "delta_background_vs_K_for_strains_2sd_outside_mean_K", delta_bg_outside_2sd_k_plots)
|
||||||
|
|
||||||
# Process background strains
|
# Process background strains
|
||||||
bg_strains <- c("YDL227C")
|
bg_strains <- c("YDL227C")
|
||||||
|
|||||||
Reference in New Issue
Block a user