annotate xcms.r @ 20:a79d839d625f draft

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