diff --git a/DIMS/CollectFilled.R b/DIMS/CollectFilled.R index 69f9e04..726fb60 100755 --- a/DIMS/CollectFilled.R +++ b/DIMS/CollectFilled.R @@ -27,7 +27,7 @@ for (scanmode in scanmodes) { repl_pattern <- get(load(pattern_file)) # calculate Z-scores if (z_score == 1) { - outlist_stats <- calculate_zscores(outlist_total, adducts = FALSE) + outlist_stats <- calculate_zscores(outlist_total) nr_removed_samples <- length(which(repl_pattern[] == "character(0)")) order_index_int <- order(colnames(outlist_stats)[8:(length(repl_pattern) - nr_removed_samples + 7)]) outlist_stats_more <- cbind( diff --git a/DIMS/EvaluateTics.R b/DIMS/EvaluateTics.R index 1598986..37e672a 100644 --- a/DIMS/EvaluateTics.R +++ b/DIMS/EvaluateTics.R @@ -13,6 +13,10 @@ highest_mz_file <- cmd_args[5] highest_mz <- get(load(highest_mz_file)) trim_params_filepath <- cmd_args[6] thresh2remove <- 1000000000 +preprocessing_scripts_dir <- cmd_args[7] + +# load functions +source(paste0(preprocessing_scripts_dir, "evaluate_tics_functions.R")) # load init_file: contains repl_pattern load(init_file) @@ -41,35 +45,11 @@ remove_neg <- remove_tech_reps$neg repl_pattern_filtered <- remove_from_repl_pattern(remove_neg, repl_pattern, nr_replicates) save(repl_pattern_filtered, file = "negative_repl_pattern.RData") -# write output for QC info on missed infusions -if (is.null(remove_neg)) { - remove_neg <- "none" -} -write.table( - remove_neg, - file = "miss_infusions_negative.txt", - row.names = FALSE, - col.names = FALSE, - sep = "\t" -) - # positive scan mode remove_pos <- remove_tech_reps$pos repl_pattern_filtered <- remove_from_repl_pattern(remove_pos, repl_pattern, nr_replicates) save(repl_pattern_filtered, file = "positive_repl_pattern.RData") -# write output for QC info on missed infusions -if (is.null(remove_pos)) { - remove_pos <- "none" -} -write.table( - remove_pos, - file = "miss_infusions_positive.txt", - row.names = FALSE, - col.names = FALSE, - sep = "\t" -) - # get an overview of suitable technical replicates for both scan modes allsamples_techreps_neg <- get_overview_tech_reps(repl_pattern_filtered, "negative") allsamples_techreps_pos <- get_overview_tech_reps(repl_pattern_filtered, "positive") @@ -81,6 +61,7 @@ write.table(allsamples_techreps_both_scanmodes, sep = "," ) + ## generate TIC plots # get all txt files tic_files <- list.files("./", full.names = TRUE, pattern = "*TIC.txt") @@ -158,3 +139,4 @@ tic_plot_pdf <- marrangeGrob( ggsave(filename = paste0(run_name, "_TICplots.pdf"), tic_plot_pdf, width = 21, height = 29.7, units = "cm") + diff --git a/DIMS/EvaluateTics.nf b/DIMS/EvaluateTics.nf index fdf7f71..2cd8bb5 100644 --- a/DIMS/EvaluateTics.nf +++ b/DIMS/EvaluateTics.nf @@ -26,7 +26,8 @@ process EvaluateTics { $analysis_id \ $params.matrix \ $highest_mz_file \ - $trim_params_file + $trim_params_file \ + $params.preprocessing_scripts_dir """ } diff --git a/DIMS/SpectrumPeakFinding.R b/DIMS/SpectrumPeakFinding.R deleted file mode 100644 index 8b249e2..0000000 --- a/DIMS/SpectrumPeakFinding.R +++ /dev/null @@ -1,61 +0,0 @@ -## adapted from 5-collectSamples.R - -# define parameters -scanmodes <- c("positive", "negative") - -# Check whether all jobs terminated correctly -not_run <- NULL - -# collect spectrum peaks for each scanmode -for (scanmode in scanmodes) { - # load peak lists of all biological samples - peaklist_files <- list.files(pattern = paste0("_", scanmode, ".RData")) - - # get sample names - load(paste0(scanmode, "_repl_pattern.RData")) - group_names <- names(repl_pattern_filtered) - for (sample_nr in 1:length(group_names)) { - group <- paste0(group_names[sample_nr], "_", scanmode, ".RData") - if (!(group %in% peaklist_files)) { - not_run <- c(not_run, group) - } - } - - # Collecting samples - outlist_total <- NULL - for (file_nr in 1:length(peaklist_files)) { - cat("\n", peaklist_files[file_nr]) - load(peaklist_files[file_nr]) - if (is.null(outlist_persample) || (dim(outlist_persample)[1] == 0)) { - tmp <- strsplit(peaklist_files[file_nr], "/")[[1]] - fname <- tmp[length(tmp)] - fname <- strsplit(fname, ".RData")[[1]][1] - fname <- substr(fname, 13, nchar(fname)) - if (file_nr == 1) { - outlist_total <- c(fname, rep("-1", 5)) - } else { - outlist_total <- rbind(outlist_total, c(fname, rep("-1", 5))) - } - } else { - if (file_nr == 1) { - outlist_total <- outlist_persample - } else { - outlist_total <- rbind(outlist_total, outlist_persample) - } - } - } - - # remove negative values - index <- which(outlist_total[, "height.pkt"] <= 0) - if (length(index) > 0) outlist_total <- outlist_total[-index, ] - index <- which(outlist_total[, "mzmed.pkt"] <= 0) - if (length(index) > 0) outlist_total <- outlist_total[-index, ] - - save(outlist_total, file = paste0("./SpectrumPeaks_", scanmode, ".RData")) - - if (!is.null(not_run)) { - for (i in 1:length(not_run)) { - message(paste(not_run[i], "was not generated")) - } - } -} diff --git a/DIMS/SpectrumPeakFinding.nf b/DIMS/SpectrumPeakFinding.nf deleted file mode 100644 index 3590265..0000000 --- a/DIMS/SpectrumPeakFinding.nf +++ /dev/null @@ -1,18 +0,0 @@ -process SpectrumPeakFinding { - tag "DIMS SpectrumPeakFinding" - label 'SpectrumPeakFinding' - container = 'docker://umcugenbioinf/dims:1.3' - shell = ['/bin/bash', '-euo', 'pipefail'] - - input: - path(rdata_files) - path(replication_pattern) - - output: - path 'SpectrumPeaks_*.RData' - - script: - """ - Rscript ${baseDir}/CustomModules/DIMS/SpectrumPeakFinding.R - """ -} diff --git a/DIMS/preprocessing/peak_finding_functions.R b/DIMS/preprocessing/peak_finding_functions.R index 8539c03..d4e825d 100644 --- a/DIMS/preprocessing/peak_finding_functions.R +++ b/DIMS/preprocessing/peak_finding_functions.R @@ -83,7 +83,7 @@ search_regions_of_interest <- function(ints_fullrange) { # sort on first index if (nrow(regions_of_interest_final) > 1){ - regions_of_interest_sorted <- regions_of_interest_final %>% dplyr::arrange(from) + regions_of_interest_sorted <- regions_of_interest_final %>% as.data.frame %>% dplyr::arrange(from) } else { regions_of_interest_sorted <- regions_of_interest_final }