Mercurial > repos > lecorguille > xcms_fillpeaks
comparison xcms_fillpeaks.r @ 28:a8d866a71ba1 draft default tip
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
author | workflow4metabolomics |
---|---|
date | Mon, 03 Feb 2025 14:44:29 +0000 |
parents | bb9ee352fce0 |
children |
comparison
equal
deleted
inserted
replaced
27:ec9aebabc1d2 | 28:a8d866a71ba1 |
---|---|
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) { | 13 source_local <- function(fname) { |
14 argv <- commandArgs(trailingOnly = FALSE) | 14 argv <- commandArgs(trailingOnly = FALSE) |
15 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)) | 15 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)) |
16 source(paste(base_dir, fname, sep = "/")) | 16 source(paste(base_dir, fname, sep = "/")) |
17 } | 17 } |
18 source_local("lib.r") | 18 source_local("lib.r") |
19 | 19 |
20 pkgs <- c("xcms", "batch") | 20 pkgs <- c("xcms", "batch") |
21 loadAndDisplayPackages(pkgs) | 21 loadAndDisplayPackages(pkgs) |
22 cat("\n\n") | 22 cat("\n\n") |
23 | 23 |
24 | 24 |
25 # ----- ARGUMENTS ----- | 25 # ----- ARGUMENTS ----- |
26 cat("\tARGUMENTS INFO\n") | 26 cat("\tARGUMENTS INFO\n") |
27 args <- parseCommandArgs(evaluate = FALSE) #interpretation of arguments given in command line as an R list of objects | 27 args <- parseCommandArgs(evaluate = FALSE) # interpretation of arguments given in command line as an R list of objects |
28 write.table(as.matrix(args), col.names = FALSE, quote = FALSE, sep = "\t") | 28 write.table(as.matrix(args), col.names = FALSE, quote = FALSE, sep = "\t") |
29 | 29 |
30 cat("\n\n") | 30 cat("\n\n") |
31 | 31 |
32 # ----- PROCESSING INFILE ----- | 32 # ----- PROCESSING INFILE ----- |
33 cat("\tARGUMENTS PROCESSING INFO\n") | 33 cat("\tARGUMENTS PROCESSING INFO\n") |
34 | 34 |
35 #saving the specific parameters | 35 # saving the specific parameters |
36 method <- "FillChromPeaks" | 36 method <- "FillChromPeaks" |
37 | 37 |
38 if (!is.null(args$convertRTMinute)) convertRTMinute <- args$convertRTMinute | 38 if (!is.null(args$convertRTMinute)) convertRTMinute <- args$convertRTMinute |
39 if (!is.null(args$numDigitsMZ)) numDigitsMZ <- args$numDigitsMZ | 39 if (!is.null(args$numDigitsMZ)) numDigitsMZ <- args$numDigitsMZ |
40 if (!is.null(args$numDigitsRT)) numDigitsRT <- args$numDigitsRT | 40 if (!is.null(args$numDigitsRT)) numDigitsRT <- args$numDigitsRT |
45 | 45 |
46 | 46 |
47 # ----- ARGUMENTS PROCESSING ----- | 47 # ----- ARGUMENTS PROCESSING ----- |
48 cat("\tINFILE PROCESSING INFO\n") | 48 cat("\tINFILE PROCESSING INFO\n") |
49 | 49 |
50 #image is an .RData file necessary to use xset variable given by previous tools | 50 # image is an .RData file necessary to use xset variable given by previous tools |
51 load(args$image) | 51 load(args$image) |
52 if (!exists("xdata")) stop("\n\nERROR: The RData doesn't contain any object called 'xdata'. This RData should have been created by an old version of XMCS 2.*") | 52 if (!exists("xdata")) stop("\n\nERROR: The RData doesn't contain any object called 'xdata'. This RData should have been created by an old version of XMCS 2.*") |
53 | 53 |
54 #Verification of a group step before doing the fillpeaks job. | 54 # Verification of a group step before doing the fillpeaks job. |
55 if (!hasFeatures(xdata)) stop("You must always do a group step after a retcor. Otherwise it won't work for the fillpeaks step") | 55 if (!hasFeatures(xdata)) stop("You must always do a group step after a retcor. Otherwise it won't work for the fillpeaks step") |
56 | 56 |
57 # Handle infiles | 57 # Handle infiles |
58 if (!exists("singlefile")) singlefile <- NULL | 58 if (!exists("singlefile")) singlefile <- NULL |
59 if (!exists("zipfile")) zipfile <- NULL | 59 if (!exists("zipfile")) zipfile <- NULL |
81 xdata <- updateObject(xdata) | 81 xdata <- updateObject(xdata) |
82 register(SerialParam()) | 82 register(SerialParam()) |
83 xdata <- fillChromPeaks(xdata, param = fillChromPeaksParam) | 83 xdata <- fillChromPeaks(xdata, param = fillChromPeaksParam) |
84 | 84 |
85 if (exists("intval")) { | 85 if (exists("intval")) { |
86 getPeaklistW4M(xdata, intval, convertRTMinute, numDigitsMZ, numDigitsRT, naTOzero, "variableMetadata.tsv", "dataMatrix.tsv") | 86 getPeaklistW4M(xdata, intval, convertRTMinute, numDigitsMZ, numDigitsRT, naTOzero, "variableMetadata.tsv", "dataMatrix.tsv") |
87 } | 87 } |
88 | 88 |
89 cat("\n\n") | 89 cat("\n\n") |
90 | 90 |
91 # ----- EXPORT ----- | 91 # ----- EXPORT ----- |
98 # Get the legacy xcmsSet object | 98 # Get the legacy xcmsSet object |
99 xset <- getxcmsSetObject(xdata) | 99 xset <- getxcmsSetObject(xdata) |
100 print(xset) | 100 print(xset) |
101 cat("\n\n") | 101 cat("\n\n") |
102 | 102 |
103 #saving R data in .Rdata file to save the variables used in the present tool | 103 # saving R data in .Rdata file to save the variables used in the present tool |
104 objects2save <- c("xdata", "zipfile", "singlefile", "md5sumList", "sampleNamesList") #, "chromTIC", "chromBPI", "chromTIC_adjusted", "chromBPI_adjusted") | 104 objects2save <- c("xdata", "zipfile", "singlefile", "md5sumList", "sampleNamesList") # , "chromTIC", "chromBPI", "chromTIC_adjusted", "chromBPI_adjusted") |
105 save(list = objects2save[objects2save %in% ls()], file = "fillpeaks.RData") | 105 save(list = objects2save[objects2save %in% ls()], file = "fillpeaks.RData") |
106 | 106 |
107 cat("\n\n") | 107 cat("\n\n") |
108 | 108 |
109 | 109 |