annotate CAMERA_groupFWHM.R @ 0:6aea0427511e draft default tip

planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
author workflow4metabolomics
date Sun, 24 Nov 2024 21:28:57 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
1 #!/usr/bin/env Rscript
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
2
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
3 # ----- PACKAGE -----
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
4 cat("\tSESSION INFO\n")
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
5
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
6 # Import the different functions
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
7 source_local <- function(fname) {
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
8 argv <- commandArgs(trailingOnly = FALSE)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
9 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
10 source(paste(base_dir, fname, sep = "/"))
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
11 }
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
12 source_local("lib.r")
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
13
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
14 pkgs <- c("CAMERA", "xcms", "multtest", "batch")
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
15 loadAndDisplayPackages(pkgs)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
16 cat("\n\n")
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
17 # ----- ARGUMENTS -----
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
18 cat("\tARGUMENTS INFO\n")
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
19
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
20 args <- parseCommandArgs(evaluate = FALSE) # interpretation of arguments given in command line as an R list of objects
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
21 write.table(as.matrix(args), col.names = FALSE, quote = FALSE, sep = "\t")
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
22
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
23 cat("\n\n")
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
24
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
25 print("Arguments retrieved from the command line:")
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
26 print(args)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
27
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
28 # Function to convert "NA" strings to actual NA values and string lists to numeric lists
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
29 convertStringToNumeric <- function(x) {
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
30 # Force conversion to character
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
31 x <- as.character(x)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
32
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
33 if (x == "NA") {
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
34 return(NA)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
35 } else if (grepl("^[0-9]+$", x)) {
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
36 # If the string represents a single numeric value
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
37 return(as.numeric(x))
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
38 } else {
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
39 # Convert string representation of a list to a numeric vector
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
40 # Use a regular expression to split by common separators
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
41 return(as.numeric(unlist(strsplit(x, "[,;\\s]+"))))
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
42 }
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
43 }
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
44
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
45 # Convert only the 'sample' element in args
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
46 args$sample <- convertStringToNumeric(args$sample)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
47
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
48 print("Argument types:")
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
49 print(sapply(args, class))
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
50
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
51 # Check if the image file exists
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
52 if (!file.exists(args$image)) {
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
53 stop("The RData file does not exist: ", args$image)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
54 }
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
55
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
56 # ----- PROCESSING INFILE -----
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
57
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
58 # Load the RData file (it should contain the xset object, typically an xcmsSet or XCMSnExp)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
59 load(args$image)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
60 args$image <- NULL
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
61
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
62 # Save arguments to generate a report
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
63 if (!exists("listOFlistArguments")) listOFlistArguments <- list()
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
64 listOFlistArguments[[format(Sys.time(), "%y%m%d-%H:%M:%S_groupFWHM")]] <- args
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
65
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
66 # We unzip automatically the chromatograms from the zip files.
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
67 if (!exists("zipfile")) zipfile <- NULL
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
68 if (!exists("singlefile")) singlefile <- NULL
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
69 rawFilePath <- getRawfilePathFromArguments(singlefile, zipfile, args)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
70 zipfile <- rawFilePath$zipfile
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
71 singlefile <- rawFilePath$singlefile
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
72 args <- rawFilePath$args
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
73
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
74 print(paste("singlefile :", singlefile))
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
75 if (!is.null(singlefile)) {
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
76 directory <- retrieveRawfileInTheWorkingDir(singlefile, zipfile)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
77 }
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
78
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
79 # If the xdata object exists, convert it to xcmsSet
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
80 if (exists("xdata")) {
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
81 phenoData <- xdata@phenoData
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
82 xset <- getxcmsSetObject(xdata)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
83 }
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
84
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
85 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.*")
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
86
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
87 # Verification of a group step before doing the fillpeaks job.
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
88 if (dim(xdata@phenoData@data)[1] > 1) {
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
89 if (!hasFeatures(xdata)) stop("You must always do a group step after a retcor. Otherwise it won't work for the groupFWHM step")
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
90 } else {
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
91 print("Only one file in the phenoData keep xset as is")
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
92 }
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
93
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
94 # Convert the xset object to xsAnnotate using CAMERA
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
95 cat("Converting xset object to xsAnnotate...\n")
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
96 xsa <- xsAnnotate(xset, sample = args$sample, nSlaves = as.numeric(args$nSlaves), polarity = args$polarity)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
97
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
98 print(paste0("All samples in xset object: ", paste(seq_along(xset@filepaths), collapse = ", ")))
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
99 print(paste0("Selected samples: ", paste(xsa@sample, collapse = ", ")))
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
100 print(paste0("Run in parallel mode (0 = disabled): ", paste(xsa@runParallel)))
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
101 print(paste0("Polarity: ", xsa@polarity))
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
102
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
103 # Apply the groupFWHM function with the parameters
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
104 cat("Applying groupFWHM...\n")
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
105 xa <- groupFWHM(xsa, sigma = as.numeric(args$sigma), perfwhm = as.numeric(args$perfwhm), intval = args$intval)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
106
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
107 # Extract the list of annotated peaks
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
108 peakList <- getPeaklist(xa, intval = args$intval)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
109
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
110 if (length(phenoData@data$sample_name) == 1) {
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
111 peakList$name <- make.unique(paste0("M", round(peakList[, "mz"], 0), "T", round(peakList[, "rt"], 0)), "_")
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
112 variableMetadata <- peakList[, c("name", setdiff(names(peakList), "name"))]
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
113 variableMetadata <- formatIonIdentifiers(variableMetadata, numDigitsRT = args$numDigitsRT, numDigitsMZ = args$numDigitsMZ)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
114 } else {
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
115 names_default <- groupnames(xa@xcmsSet, mzdec = 0, rtdec = 0) # Names without decimals
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
116 names_custom <- groupnames(xa@xcmsSet, mzdec = args$numDigitsMZ, rtdec = args$numDigitsRT) # Names with "x" decimals
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
117
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
118 variableMetadata <- data.frame(
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
119 name = names_default,
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
120 name_custom = names_custom,
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
121 stringsAsFactors = FALSE
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
122 )
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
123 variableMetadata <- cbind(variableMetadata, peakList[, !(make.names(colnames(peakList)) %in% c(make.names(sampnames(xa@xcmsSet))))])
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
124 }
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
125
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
126 if (!exists("RTinMinute")) RTinMinute <- FALSE
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
127
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
128 if (args$convertRTMinute && RTinMinute == FALSE) {
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
129 RTinMinute <- TRUE
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
130 variableMetadata <- RTSecondToMinute(variableMetadata = variableMetadata, convertRTMinute = args$convertRTMinute)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
131 }
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
132
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
133 # Save the peak list to a TSV file
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
134 output_file_tsv <- "variableMetadata.tsv"
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
135 write.table(variableMetadata, file = output_file_tsv, sep = "\t", row.names = FALSE, quote = FALSE)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
136
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
137 # Save the xsAnnotate object
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
138 output_file_RData <- "camera_fwhm.RData"
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
139 objects2save <- c("xa", "variableMetadata", "listOFlistArguments", "zipfile", "singlefile", "RTinMinute", "phenoData")
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
140 save(list = objects2save[objects2save %in% ls()], file = output_file_RData)
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
141
6aea0427511e planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
workflow4metabolomics
parents:
diff changeset
142 cat("Output files generated:", output_file_tsv, "and", output_file_RData, "\n")