Add new configuration file

This commit is contained in:
2024-08-22 04:20:40 -04:00
parent a300484ceb
commit bcc8dba3e4
8 changed files with 1824 additions and 1016 deletions

View File

@@ -14,7 +14,7 @@ BASE_SIZE <- 14
options(warn = 2, max.print = 100)
# Function to parse arguments
# Parse arguments
parse_arguments <- function() {
if (interactive()) {
args <- c(
@@ -92,7 +92,7 @@ scale_colour_publication <- function(...) {
)), ...)
}
# Function to load and preprocess data
# Load and preprocess data
load_and_preprocess_data <- function(input_file) {
df <- tryCatch({
read.delim(input_file, skip = 2, as.is = TRUE, row.names = 1, strip.white = TRUE)
@@ -124,7 +124,7 @@ df <- df %>%
mutate(OrfRep = if_else(ORF == "YDL227C", "YDL227C", OrfRep)) %>%
filter(!Gene %in% c("BLANK", "Blank", "blank"), Drug != "BMH21")
# Function to create plot
# Create plot
create_plot <- function(df, var, plot_type) {
filtered_df <- df %>% filter(is.finite(.data[[var]]))
p <- ggplot(filtered_df, aes(Scan, .data[[var]], color = as.factor(conc_num))) +
@@ -143,7 +143,7 @@ create_plot <- function(df, var, plot_type) {
return(p)
}
# Function to publish plot to PDF and HTML (Plotly)
# Publish plot to PDF and HTML (Plotly)
publish_plot <- function(plot, plot_path) {
# if (file.exists(plot_path)) {
# file.rename(plot_path, paste0(plot_path, BACKUP_SUFFIX))
@@ -153,13 +153,13 @@ publish_plot <- function(plot, plot_path) {
print(plot)
dev.off()
pgg <- suppressWarnings(ggplotly(plot,
pgg <- suppressWarnings(ggplotly(plot,
tooltip = c("L", "K", "ORF", "Gene", "delta_bg")) %>%
layout(legend = list(orientation = "h")))
saveWidget(pgg, sub(".pdf$", ".html", plot_path), selfcontained = TRUE)
}
# Function to publish multiple plots
# Publish multiple plots
publish_multiple_plots <- function(df, variables, plot_type, out_dir_qc, suffix = "") {
lapply(variables, function(var) {
plot <- create_plot(df, var, plot_type)
@@ -167,7 +167,7 @@ publish_multiple_plots <- function(df, variables, plot_type, out_dir_qc, suffix
})
}
# Function to calculate and publish summary statistics
# Calculate and publish summary statistics
publish_summary_stats <- function(df, variables, out_dir) {
stats_list <- lapply(variables, function(var) {
df %>%
@@ -183,7 +183,7 @@ publish_summary_stats <- function(df, variables, out_dir) {
write.csv(summary_stats_df, file.path(out_dir, "summary_stats_all_strains.csv"), row.names = FALSE)
}
# Function to calculate and publish interaction scores
# Calculate and publish interaction scores
publish_interaction_scores <- function(df, out_dir) {
interaction_scores <- df %>%
group_by(OrfRep) %>%
@@ -207,7 +207,7 @@ publish_interaction_scores <- function(df, out_dir) {
arrange(l_rank, k_rank), file.path(out_dir, "rf_zscores_interaction_ranked.csv"), row.names = FALSE)
}
# Function to publish z-scores
# Publish z-scores
publish_zscores <- function(df, out_dir) {
zscores <- df %>%
mutate(