Add rank plots
This commit is contained in:
@@ -565,6 +565,46 @@ generate_plots <- function(df, x_var, y_vars, plot_type, color_var = "conc_num",
|
|||||||
save_plots(file_prefix, plot_list, output_dir)
|
save_plots(file_prefix, plot_list, output_dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to generate rank plots for the provided dataframe
|
||||||
|
generate_rank_plots <- function(df, output_dir) {
|
||||||
|
# Adjust missing values and calculate ranks
|
||||||
|
df_adjusted <- adjust_missing_and_rank(df)
|
||||||
|
|
||||||
|
# List of variables for which we need to generate rank plots
|
||||||
|
variables <- c("L", "K", "r", "AUC")
|
||||||
|
|
||||||
|
# Generate rank plots for Avg_Zscore and Z_lm
|
||||||
|
for (var in variables) {
|
||||||
|
plot_rank_avg <- generate_plot(
|
||||||
|
df = df_adjusted,
|
||||||
|
x_var = paste0(var, "_Rank"),
|
||||||
|
y_var = paste0("Avg_Zscore_", var),
|
||||||
|
plot_type = "scatter",
|
||||||
|
title = paste("Average Z score vs Rank for", var)
|
||||||
|
)
|
||||||
|
|
||||||
|
plot_rank_lm <- generate_plot(
|
||||||
|
df = df_adjusted,
|
||||||
|
x_var = paste0(var, "_Rank_lm"),
|
||||||
|
y_var = paste0("Z_lm_", var),
|
||||||
|
plot_type = "scatter",
|
||||||
|
title = paste("Interaction Z score vs Rank for", var)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Save the plots for Avg_Zscore and Z_lm
|
||||||
|
save_plots(paste0("RankPlots_", var), list(
|
||||||
|
plot_rank_avg = plot_rank_avg,
|
||||||
|
plot_rank_lm = plot_rank_lm
|
||||||
|
), output_dir)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to call rank plot generation in the main function
|
||||||
|
create_ranked_plots <- function(df, output_dir) {
|
||||||
|
message("Generating rank plots")
|
||||||
|
generate_rank_plots(df, output_dir)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
main <- function() {
|
main <- function() {
|
||||||
lapply(names(args$experiments), function(exp_name) {
|
lapply(names(args$experiments), function(exp_name) {
|
||||||
@@ -614,9 +654,6 @@ main <- function() {
|
|||||||
write.csv(stats, file = file.path(out_dir, "SummaryStats_ALLSTRAINS.csv"), row.names = FALSE)
|
write.csv(stats, file = file.path(out_dir, "SummaryStats_ALLSTRAINS.csv"), row.names = FALSE)
|
||||||
stats_joined <- left_join(df_na, stats, by = c("OrfRep", "conc_num", "conc_num_factor"))
|
stats_joined <- left_join(df_na, stats, by = c("OrfRep", "conc_num", "conc_num_factor"))
|
||||||
|
|
||||||
# Create interaction plots
|
|
||||||
generate_interaction_plots(stats_joined, output_file = file.path(output_dir, "InteractionPlots.pdf"))
|
|
||||||
|
|
||||||
print("stats:")
|
print("stats:")
|
||||||
print(head(stats))
|
print(head(stats))
|
||||||
|
|
||||||
@@ -711,10 +748,9 @@ main <- function() {
|
|||||||
write.csv(zscores_interactions_reference, file = file.path(out_dir, "RF_ZScores_Interaction.csv"), row.names = FALSE)
|
write.csv(zscores_interactions_reference, file = file.path(out_dir, "RF_ZScores_Interaction.csv"), row.names = FALSE)
|
||||||
write.csv(zscores_interactions, file = file.path(out_dir, "ZScores_Interaction.csv"), row.names = FALSE)
|
write.csv(zscores_interactions, file = file.path(out_dir, "ZScores_Interaction.csv"), row.names = FALSE)
|
||||||
|
|
||||||
|
# Create interaction plots
|
||||||
|
generate_interaction_plots(df_reference, output_file = file.path(output_dir, "RF_InteractionPlots.pdf"))
|
||||||
|
generate_interaction_plots(df_deletion, output_file = file.path(output_dir, "InteractionPlots.pdf"))
|
||||||
|
|
||||||
|
|
||||||
# Define conditions for enhancers and suppressors
|
# Define conditions for enhancers and suppressors
|
||||||
# TODO Add to study config file?
|
# TODO Add to study config file?
|
||||||
|
|||||||
Reference in New Issue
Block a user