Mercurial > repos > lecorguille > xcms_fillpeaks
comparison xcms_fillpeaks.r @ 45:1a711c1b8b1f draft
"planemo upload for repository https://github.com/workflow4metabolomics/xcms commit dcc90f9cf76e6980c0a7d9698c89fab826e7adae"
| author | workflow4metabolomics |
|---|---|
| date | Wed, 07 Apr 2021 10:28:50 +0000 |
| parents | 1b5fb5a27f5e |
| children | 871ffc15a6da |
comparison
equal
deleted
inserted
replaced
| 44:1b5fb5a27f5e | 45:1a711c1b8b1f |
|---|---|
| 1 #!/usr/bin/env Rscript | 1 #!/usr/bin/env Rscript |
| 2 | 2 |
| 3 # ----- LOG FILE ----- | 3 # ----- LOG FILE ----- |
| 4 log_file=file("log.txt", open = "wt") | 4 log_file <- file("log.txt", open = "wt") |
| 5 sink(log_file) | 5 sink(log_file) |
| 6 sink(log_file, type = "output") | 6 sink(log_file, type = "output") |
| 7 | 7 |
| 8 | 8 |
| 9 # ----- PACKAGE ----- | 9 # ----- PACKAGE ----- |
| 10 cat("\tSESSION INFO\n") | 10 cat("\tSESSION INFO\n") |
| 11 | 11 |
| 12 #Import the different functions | 12 #Import the different functions |
| 13 source_local <- function(fname){ argv <- commandArgs(trailingOnly=FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) } | 13 source_local <- function(fname) { |
| 14 argv <- commandArgs(trailingOnly = FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep = "/")) | |
| 15 } | |
| 14 source_local("lib.r") | 16 source_local("lib.r") |
| 15 | 17 |
| 16 pkgs <- c("xcms","batch") | 18 pkgs <- c("xcms", "batch") |
| 17 loadAndDisplayPackages(pkgs) | 19 loadAndDisplayPackages(pkgs) |
| 18 cat("\n\n"); | 20 cat("\n\n"); |
| 19 | 21 |
| 20 | 22 |
| 21 # ----- ARGUMENTS ----- | 23 # ----- ARGUMENTS ----- |
| 22 cat("\tARGUMENTS INFO\n") | 24 cat("\tARGUMENTS INFO\n") |
| 23 args = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects | 25 args <- parseCommandArgs(evaluate = FALSE) #interpretation of arguments given in command line as an R list of objects |
| 24 write.table(as.matrix(args), col.names=F, quote=F, sep='\t') | 26 write.table(as.matrix(args), col.names = F, quote = F, sep = "\t") |
| 25 | 27 |
| 26 cat("\n\n") | 28 cat("\n\n") |
| 27 | 29 |
| 28 # ----- PROCESSING INFILE ----- | 30 # ----- PROCESSING INFILE ----- |
| 29 cat("\tARGUMENTS PROCESSING INFO\n") | 31 cat("\tARGUMENTS PROCESSING INFO\n") |
| 51 if (!hasFeatures(xdata)) stop("You must always do a group step after a retcor. Otherwise it won't work for the fillpeaks step") | 53 if (!hasFeatures(xdata)) stop("You must always do a group step after a retcor. Otherwise it won't work for the fillpeaks step") |
| 52 | 54 |
| 53 # Handle infiles | 55 # Handle infiles |
| 54 if (!exists("singlefile")) singlefile <- NULL | 56 if (!exists("singlefile")) singlefile <- NULL |
| 55 if (!exists("zipfile")) zipfile <- NULL | 57 if (!exists("zipfile")) zipfile <- NULL |
| 56 rawFilePath <- retrieveRawfileInTheWorkingDirectory(singlefile, zipfile, args) | 58 rawFilePath <- retrieveRawfileInTheWorkingDir(singlefile, zipfile, args) |
| 57 zipfile <- rawFilePath$zipfile | 59 zipfile <- rawFilePath$zipfile |
| 58 singlefile <- rawFilePath$singlefile | 60 singlefile <- rawFilePath$singlefile |
| 59 | 61 |
| 60 | 62 |
| 61 cat("\n\n") | 63 cat("\n\n") |
| 66 | 68 |
| 67 cat("\t\tCOMPUTE\n") | 69 cat("\t\tCOMPUTE\n") |
| 68 | 70 |
| 69 cat("\t\t\tFilling missing peaks using default settings\n") | 71 cat("\t\t\tFilling missing peaks using default settings\n") |
| 70 # clear the arguement list to remove unexpected key/value as singlefile_galaxyPath or method ... | 72 # clear the arguement list to remove unexpected key/value as singlefile_galaxyPath or method ... |
| 71 args <- args[names(args) %in% slotNames(do.call(paste0(method,"Param"), list()))] | 73 args <- args[names(args) %in% slotNames(do.call(paste0(method, "Param"), list()))] |
| 72 | 74 |
| 73 fillChromPeaksParam <- do.call(paste0(method,"Param"), args) | 75 fillChromPeaksParam <- do.call(paste0(method, "Param"), args) |
| 74 print(fillChromPeaksParam) | 76 print(fillChromPeaksParam) |
| 75 | 77 |
| 76 # back compatibility between xcms-3.0.0 and xcms-3.5.2 | 78 # back compatibility between xcms-3.0.0 and xcms-3.5.2 |
| 77 xdata <- updateObject(xdata) | 79 xdata <- updateObject(xdata) |
| 78 register(SerialParam()) | 80 register(SerialParam()) |
| 79 xdata <- fillChromPeaks(xdata, param=fillChromPeaksParam) | 81 xdata <- fillChromPeaks(xdata, param = fillChromPeaksParam) |
| 80 | 82 |
| 81 if (exists("intval")) { | 83 if (exists("intval")) { |
| 82 getPeaklistW4M(xdata, intval, convertRTMinute, numDigitsMZ, numDigitsRT, naTOzero, "variableMetadata.tsv", "dataMatrix.tsv") | 84 getPeaklistW4M(xdata, intval, convertRTMinute, numDigitsMZ, numDigitsRT, naTOzero, "variableMetadata.tsv", "dataMatrix.tsv") |
| 83 } | 85 } |
| 84 | 86 |
| 95 xset <- getxcmsSetObject(xdata) | 97 xset <- getxcmsSetObject(xdata) |
| 96 print(xset) | 98 print(xset) |
| 97 cat("\n\n") | 99 cat("\n\n") |
| 98 | 100 |
| 99 #saving R data in .Rdata file to save the variables used in the present tool | 101 #saving R data in .Rdata file to save the variables used in the present tool |
| 100 objects2save = c("xdata","zipfile","singlefile","md5sumList","sampleNamesList") #, "chromTIC", "chromBPI", "chromTIC_adjusted", "chromBPI_adjusted") | 102 objects2save <- c("xdata", "zipfile", "singlefile", "md5sumList", "sampleNamesList") #, "chromTIC", "chromBPI", "chromTIC_adjusted", "chromBPI_adjusted") |
| 101 save(list=objects2save[objects2save %in% ls()], file="fillpeaks.RData") | 103 save(list = objects2save[objects2save %in% ls()], file = "fillpeaks.RData") |
| 102 | 104 |
| 103 cat("\n\n") | 105 cat("\n\n") |
| 104 | 106 |
| 105 | 107 |
| 106 cat("\tDONE\n") | 108 cat("\tDONE\n") |
