annotate xcms.r @ 22:411d2b9ea412 draft

planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 87dc789d7cd70a3733a1ad0b5a427f4d5905795d
author lecorguille
date Wed, 01 Mar 2017 16:57:27 -0500
parents 2faecb1270fe
children 38fa090ae98f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
1 #!/usr/bin/env Rscript
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
2 # xcms.r version="2.2.0"
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
3 #Authors ABIMS TEAM
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
4 #BPC Addition from Y.guitton
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
5
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
7 # ----- LOG FILE -----
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
8 log_file=file("log.txt", open = "wt")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
9 sink(log_file)
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
10 sink(log_file, type = "output")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
11
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
12
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
13 # ----- PACKAGE -----
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
14 cat("\tPACKAGE INFO\n")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
15 #pkgs=c("xcms","batch")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
16 pkgs=c("parallel","BiocGenerics", "Biobase", "Rcpp", "mzR", "xcms","snow","batch")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
17 for(pkg in pkgs) {
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
18 suppressPackageStartupMessages( stopifnot( library(pkg, quietly=TRUE, logical.return=TRUE, character.only=TRUE)))
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
19 cat(pkg,"\t",as.character(packageVersion(pkg)),"\n",sep="")
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
20 }
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
21 source_local <- function(fname){ argv <- commandArgs(trailingOnly = FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) }
15
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
22 cat("\n\n");
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
23
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
24
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
25
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
26
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
27
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
28 # ----- ARGUMENTS -----
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
29 cat("\tARGUMENTS INFO\n")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
30 listArguments = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
31 write.table(as.matrix(listArguments), col.names=F, quote=F, sep='\t')
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
32
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
33 cat("\n\n");
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
34
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
35
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
36 # ----- ARGUMENTS PROCESSING -----
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
37 cat("\tINFILE PROCESSING INFO\n")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
38
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
39 #image is an .RData file necessary to use xset variable given by previous tools
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
40 if (!is.null(listArguments[["image"]])){
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
41 load(listArguments[["image"]]); listArguments[["image"]]=NULL
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
42 }
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
43
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
44 #Import the different functions
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
45 source_local("lib.r")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
46
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
47 cat("\n\n")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
48
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
49 #Import the different functions
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
50
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
51 # ----- PROCESSING INFILE -----
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
52 cat("\tARGUMENTS PROCESSING INFO\n")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
53
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
54 # Save arguments to generate a report
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
55 if (!exists("listOFlistArguments")) listOFlistArguments=list()
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
56 listOFlistArguments[[paste(format(Sys.time(), "%y%m%d-%H:%M:%S_"),listArguments[["xfunction"]],sep="")]] = listArguments
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
57
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
58
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
59 #saving the commun parameters
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
60 thefunction = listArguments[["xfunction"]]; listArguments[["xfunction"]]=NULL #delete from the list of arguments
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
61
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
62 xsetRdataOutput = paste(thefunction,"RData",sep=".")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
63 if (!is.null(listArguments[["xsetRdataOutput"]])){
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
64 xsetRdataOutput = listArguments[["xsetRdataOutput"]]; listArguments[["xsetRdataOutput"]]=NULL
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
65 }
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
66
15
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
67 #saving the specific parameters
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
68 rplotspdf = "Rplots.pdf"
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
69 if (!is.null(listArguments[["rplotspdf"]])){
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
70 rplotspdf = listArguments[["rplotspdf"]]; listArguments[["rplotspdf"]]=NULL
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
71 }
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
72 sampleMetadataOutput = "sampleMetadata.tsv"
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
73 if (!is.null(listArguments[["sampleMetadataOutput"]])){
22
411d2b9ea412 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 87dc789d7cd70a3733a1ad0b5a427f4d5905795d
lecorguille
parents: 19
diff changeset
74 sampleMetadataOutput = listArguments[["sampleMetadataOutput"]]; listArguments[["sampleMetadataOutput"]]=NULL
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
75 }
15
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
76 variableMetadataOutput = "variableMetadata.tsv"
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
77 if (!is.null(listArguments[["variableMetadataOutput"]])){
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
78 variableMetadataOutput = listArguments[["variableMetadataOutput"]]; listArguments[["variableMetadataOutput"]]=NULL
15
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
79 }
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
80 dataMatrixOutput = "dataMatrix.tsv"
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
81 if (!is.null(listArguments[["dataMatrixOutput"]])){
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
82 dataMatrixOutput = listArguments[["dataMatrixOutput"]]; listArguments[["dataMatrixOutput"]]=NULL
15
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
83 }
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
84 if (!is.null(listArguments[["convertRTMinute"]])){
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
85 convertRTMinute = listArguments[["convertRTMinute"]]; listArguments[["convertRTMinute"]]=NULL
15
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
86 }
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
87 if (!is.null(listArguments[["numDigitsMZ"]])){
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
88 numDigitsMZ = listArguments[["numDigitsMZ"]]; listArguments[["numDigitsMZ"]]=NULL
15
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
89 }
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
90 if (!is.null(listArguments[["numDigitsRT"]])){
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
91 numDigitsRT = listArguments[["numDigitsRT"]]; listArguments[["numDigitsRT"]]=NULL
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
92 }
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
93 if (!is.null(listArguments[["intval"]])){
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
94 intval = listArguments[["intval"]]; listArguments[["intval"]]=NULL
15
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
95 }
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
96
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
97 if (thefunction %in% c("xcmsSet","retcor")) {
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
98 ticspdf = listArguments[["ticspdf"]]; listArguments[["ticspdf"]]=NULL
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
99 bicspdf = listArguments[["bicspdf"]]; listArguments[["bicspdf"]]=NULL
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
100 }
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
101
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
102
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
103 if (thefunction %in% c("xcmsSet","retcor","fillPeaks")) {
22
411d2b9ea412 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 87dc789d7cd70a3733a1ad0b5a427f4d5905795d
lecorguille
parents: 19
diff changeset
104 rawFilePath = getRawfilePathFromArguments(listArguments)
411d2b9ea412 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 87dc789d7cd70a3733a1ad0b5a427f4d5905795d
lecorguille
parents: 19
diff changeset
105 zipfile = rawFilePath$zipfile
411d2b9ea412 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 87dc789d7cd70a3733a1ad0b5a427f4d5905795d
lecorguille
parents: 19
diff changeset
106 singlefile = rawFilePath$singlefile
411d2b9ea412 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 87dc789d7cd70a3733a1ad0b5a427f4d5905795d
lecorguille
parents: 19
diff changeset
107 listArguments = rawFilePath$listArguments
411d2b9ea412 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 87dc789d7cd70a3733a1ad0b5a427f4d5905795d
lecorguille
parents: 19
diff changeset
108 directory = retrieveRawfileInTheWorkingDirectory(singlefile, zipfile)
411d2b9ea412 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 87dc789d7cd70a3733a1ad0b5a427f4d5905795d
lecorguille
parents: 19
diff changeset
109 md5sumList=list("origin"=getMd5sum(directory))
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
110 }
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
111
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
112 #addition of the directory to the list of arguments in the first position
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
113 if (thefunction == "xcmsSet") {
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
114 checkXmlStructure(directory)
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
115 checkFilesCompatibilityWithXcms(directory)
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
116 listArguments=append(directory, listArguments)
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
117 }
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
118
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
119
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
120 #addition of xset object to the list of arguments in the first position
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
121 if (exists("xset")){
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
122 listArguments=append(list(xset), listArguments)
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
123 }
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
124
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
125 cat("\n\n")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
126
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
127
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
128
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
129
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
130 # ----- MAIN PROCESSING INFO -----
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
131 cat("\tMAIN PROCESSING INFO\n")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
132
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
133
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
134 #Verification of a group step before doing the fillpeaks job.
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
135
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
136 if (thefunction == "fillPeaks") {
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
137 res=try(is.null(groupnames(xset)))
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
138 if (class(res) == "try-error"){
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
139 error<-geterrmessage()
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
140 write(error, stderr())
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
141 stop("You must always do a group step after a retcor. Otherwise it won't work for the fillpeaks step")
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
142 }
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
143
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
144 }
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
145
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
146 #change the default display settings
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
147 #dev.new(file="Rplots.pdf", width=16, height=12)
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
148 pdf(file=rplotspdf, width=16, height=12)
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
149 if (thefunction == "group") {
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
150 par(mfrow=c(2,2))
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
151 }
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
152 #else if (thefunction == "retcor") {
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
153 #try to change the legend display
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
154 # par(xpd=NA)
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
155 # par(xpd=T, mar=par()$mar+c(0,0,0,4))
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
156 #}
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
157
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
158
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
159 #execution of the function "thefunction" with the parameters given in "listArguments"
15
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
160
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
161 cat("\t\tCOMPUTE\n")
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
162 xset = do.call(thefunction, listArguments)
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
163
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
164
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
165 cat("\n\n")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
166
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
167 dev.off() #dev.new(file="Rplots.pdf", width=16, height=12)
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
168
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
169 if (thefunction == "xcmsSet") {
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
170
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
171 #transform the files absolute pathways into relative pathways
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
172 xset@filepaths<-sub(paste(getwd(),"/",sep="") ,"", xset@filepaths)
22
411d2b9ea412 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 87dc789d7cd70a3733a1ad0b5a427f4d5905795d
lecorguille
parents: 19
diff changeset
173 print(zipfile)
411d2b9ea412 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 87dc789d7cd70a3733a1ad0b5a427f4d5905795d
lecorguille
parents: 19
diff changeset
174 if(exists("zipfile") && !is.null(zipfile) && (zipfile!="")) {
15
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
175
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
176 #Modify the samples names (erase the path)
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
177 for(i in 1:length(sampnames(xset))){
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
178
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
179 sample_name=unlist(strsplit(sampnames(xset)[i], "/"))
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
180 sample_name=sample_name[length(sample_name)]
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
181 sample_name= unlist(strsplit(sample_name,"[.]"))[1]
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
182 sampnames(xset)[i]=sample_name
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
183
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
184 }
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
185
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
186 }
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
187
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
188 }
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
189
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
190 # -- TIC --
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
191 if (thefunction == "xcmsSet") {
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
192 cat("\t\tGET TIC GRAPH\n")
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
193 sampleNamesList = getSampleMetadata(xcmsSet=xset, sampleMetadataOutput=sampleMetadataOutput)
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
194 getTICs(xcmsSet=xset, pdfname=ticspdf,rt="raw")
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
195 getBPCs(xcmsSet=xset,rt="raw",pdfname=bicspdf)
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
196 } else if (thefunction == "retcor") {
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
197 cat("\t\tGET TIC GRAPH\n")
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
198 getTICs(xcmsSet=xset, pdfname=ticspdf,rt="corrected")
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
199 getBPCs(xcmsSet=xset,rt="corrected",pdfname=bicspdf)
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
200 }
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
201
19
2faecb1270fe planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 481448087f0e09c131b24f7d552db69f3552d371-dirty
lecorguille
parents: 18
diff changeset
202 if ((thefunction == "group" || thefunction == "fillPeaks") && exists("intval")) {
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
203 getPeaklistW4M(xset,intval,convertRTMinute,numDigitsMZ,numDigitsRT,variableMetadataOutput,dataMatrixOutput)
15
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
204 }
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
205
c04568596f40 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents: 6
diff changeset
206
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
207 cat("\n\n")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
208
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
209 # ----- EXPORT -----
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
210
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
211 cat("\tXSET OBJECT INFO\n")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
212 print(xset)
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
213 #delete the parameters to avoid the passage to the next tool in .RData image
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
214
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
215
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
216 #saving R data in .Rdata file to save the variables used in the present tool
16
20a75ba4345b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 22c4e92909198328fc7439ff47e4546a273eb907
lecorguille
parents: 15
diff changeset
217 objects2save = c("xset","zipfile","singlefile","listOFlistArguments","md5sumList","sampleNamesList")
6
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
218 save(list=objects2save[objects2save %in% ls()], file=xsetRdataOutput)
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
219
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
220 cat("\n\n")
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
221
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
222
fcd93f47dcbf planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
lecorguille
parents:
diff changeset
223 cat("\tDONE\n")