Mercurial > repos > lecorguille > xcms_group
comparison xcms.r @ 9:2c1d7df89cf6 draft
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
author | lecorguille |
---|---|
date | Mon, 30 Jan 2017 08:53:13 -0500 |
parents | 2db1d1d0f131 |
children | c81275aee959 |
comparison
equal
deleted
inserted
replaced
8:5d80e7511dfb | 9:2c1d7df89cf6 |
---|---|
17 for(pkg in pkgs) { | 17 for(pkg in pkgs) { |
18 suppressPackageStartupMessages( stopifnot( library(pkg, quietly=TRUE, logical.return=TRUE, character.only=TRUE))) | 18 suppressPackageStartupMessages( stopifnot( library(pkg, quietly=TRUE, logical.return=TRUE, character.only=TRUE))) |
19 cat(pkg,"\t",as.character(packageVersion(pkg)),"\n",sep="") | 19 cat(pkg,"\t",as.character(packageVersion(pkg)),"\n",sep="") |
20 } | 20 } |
21 source_local <- function(fname){ argv <- commandArgs(trailingOnly = FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) } | 21 source_local <- function(fname){ argv <- commandArgs(trailingOnly = FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) } |
22 cat("\n\n"); | 22 cat("\n\n"); |
23 | 23 |
24 | 24 |
25 | 25 |
26 | 26 |
27 | 27 |
62 xsetRdataOutput = paste(thefunction,"RData",sep=".") | 62 xsetRdataOutput = paste(thefunction,"RData",sep=".") |
63 if (!is.null(listArguments[["xsetRdataOutput"]])){ | 63 if (!is.null(listArguments[["xsetRdataOutput"]])){ |
64 xsetRdataOutput = listArguments[["xsetRdataOutput"]]; listArguments[["xsetRdataOutput"]]=NULL | 64 xsetRdataOutput = listArguments[["xsetRdataOutput"]]; listArguments[["xsetRdataOutput"]]=NULL |
65 } | 65 } |
66 | 66 |
67 #saving the specific parameters | |
67 rplotspdf = "Rplots.pdf" | 68 rplotspdf = "Rplots.pdf" |
68 if (!is.null(listArguments[["rplotspdf"]])){ | 69 if (!is.null(listArguments[["rplotspdf"]])){ |
69 rplotspdf = listArguments[["rplotspdf"]]; listArguments[["rplotspdf"]]=NULL | 70 rplotspdf = listArguments[["rplotspdf"]]; listArguments[["rplotspdf"]]=NULL |
70 } | 71 } |
71 | |
72 sampleMetadataOutput = "sampleMetadata.tsv" | 72 sampleMetadataOutput = "sampleMetadata.tsv" |
73 if (!is.null(listArguments[["sampleMetadataOutput"]])){ | 73 if (!is.null(listArguments[["sampleMetadataOutput"]])){ |
74 sampleMetadataOutput = listArguments[["sampleMetadataOutput"]]; listArguments[["sampleMetadataOutput"]]=NULL | 74 sampleMetadataOutput = listArguments[["sampleMetadataOutput"]]; listArguments[["sampleMetadataOutput"]]=NULL |
75 } | 75 } |
76 | 76 variableMetadataOutput = "variableMetadata.tsv" |
77 | 77 if (!is.null(listArguments[["variableMetadataOutput"]])){ |
78 | 78 variableMetadataOutput = listArguments[["variableMetadataOutput"]]; listArguments[["variableMetadataOutput"]]=NULL |
79 } | |
80 dataMatrixOutput = "dataMatrix.tsv" | |
81 if (!is.null(listArguments[["dataMatrixOutput"]])){ | |
82 dataMatrixOutput = listArguments[["dataMatrixOutput"]]; listArguments[["dataMatrixOutput"]]=NULL | |
83 } | |
84 if (!is.null(listArguments[["convertRTMinute"]])){ | |
85 convertRTMinute = listArguments[["convertRTMinute"]]; listArguments[["convertRTMinute"]]=NULL | |
86 } | |
87 if (!is.null(listArguments[["numDigitsMZ"]])){ | |
88 numDigitsMZ = listArguments[["numDigitsMZ"]]; listArguments[["numDigitsMZ"]]=NULL | |
89 } | |
90 if (!is.null(listArguments[["numDigitsRT"]])){ | |
91 numDigitsRT = listArguments[["numDigitsRT"]]; listArguments[["numDigitsRT"]]=NULL | |
92 } | |
93 if (!is.null(listArguments[["intval"]])){ | |
94 intval = listArguments[["intval"]]; listArguments[["intval"]]=NULL | |
95 } | |
79 | 96 |
80 if (thefunction %in% c("xcmsSet","retcor")) { | 97 if (thefunction %in% c("xcmsSet","retcor")) { |
81 ticspdf = listArguments[["ticspdf"]]; listArguments[["ticspdf"]]=NULL | 98 ticspdf = listArguments[["ticspdf"]]; listArguments[["ticspdf"]]=NULL |
82 bicspdf = listArguments[["bicspdf"]]; listArguments[["bicspdf"]]=NULL | 99 bicspdf = listArguments[["bicspdf"]]; listArguments[["bicspdf"]]=NULL |
83 } | 100 } |
114 | 131 |
115 #unzip | 132 #unzip |
116 suppressWarnings(unzip(zipfile, unzip="unzip")) | 133 suppressWarnings(unzip(zipfile, unzip="unzip")) |
117 | 134 |
118 #get the directory name | 135 #get the directory name |
119 filesInZip=unzip(zipfile, list=T); | 136 filesInZip=unzip(zipfile, list=T); |
120 directories=unique(unlist(lapply(strsplit(filesInZip$Name,"/"), function(x) x[1]))); | 137 directories=unique(unlist(lapply(strsplit(filesInZip$Name,"/"), function(x) x[1]))); |
121 directories=directories[!(directories %in% c("__MACOSX")) & file.info(directories)$isdir] | 138 directories=directories[!(directories %in% c("__MACOSX")) & file.info(directories)$isdir] |
122 directory = "." | 139 directory = "." |
123 if (length(directories) == 1) directory = directories | 140 if (length(directories) == 1) directory = directories |
124 | 141 |
125 cat("files_root_directory\t",directory,"\n") | 142 cat("files_root_directory\t",directory,"\n") |
126 | 143 |
127 # | 144 # |
128 md5sumList=list("origin"=getMd5sum(directory)) | 145 md5sumList=list("origin"=getMd5sum(directory)) |
129 | 146 |
130 # Check and fix if there are non ASCII characters. If so, they will be removed from the *mzXML mzML files. | 147 # Check and fix if there are non ASCII characters. If so, they will be removed from the *mzXML mzML files. |
131 # Remove because can create issue with some clean files | 148 # Remove because can create issue with some clean files |
132 #@TODO: fix me | 149 #@TODO: fix me |
185 # par(xpd=T, mar=par()$mar+c(0,0,0,4)) | 202 # par(xpd=T, mar=par()$mar+c(0,0,0,4)) |
186 #} | 203 #} |
187 | 204 |
188 | 205 |
189 #execution of the function "thefunction" with the parameters given in "listArguments" | 206 #execution of the function "thefunction" with the parameters given in "listArguments" |
207 | |
208 cat("\t\tCOMPUTE\n") | |
190 xset = do.call(thefunction, listArguments) | 209 xset = do.call(thefunction, listArguments) |
191 | 210 |
192 | 211 |
193 cat("\n\n") | 212 cat("\n\n") |
194 | 213 |
198 | 217 |
199 #transform the files absolute pathways into relative pathways | 218 #transform the files absolute pathways into relative pathways |
200 xset@filepaths<-sub(paste(getwd(),"/",sep="") ,"", xset@filepaths) | 219 xset@filepaths<-sub(paste(getwd(),"/",sep="") ,"", xset@filepaths) |
201 | 220 |
202 if(exists("zipfile") && (zipfile!="")) { | 221 if(exists("zipfile") && (zipfile!="")) { |
203 | 222 |
204 #Modify the samples names (erase the path) | 223 #Modify the samples names (erase the path) |
205 for(i in 1:length(sampnames(xset))){ | 224 for(i in 1:length(sampnames(xset))){ |
206 | 225 |
207 sample_name=unlist(strsplit(sampnames(xset)[i], "/")) | 226 sample_name=unlist(strsplit(sampnames(xset)[i], "/")) |
208 sample_name=sample_name[length(sample_name)] | 227 sample_name=sample_name[length(sample_name)] |
215 | 234 |
216 } | 235 } |
217 | 236 |
218 # -- TIC -- | 237 # -- TIC -- |
219 if (thefunction == "xcmsSet") { | 238 if (thefunction == "xcmsSet") { |
239 cat("\t\tGET TIC GRAPH\n") | |
220 sampleNamesList = getSampleMetadata(xcmsSet=xset, sampleMetadataOutput=sampleMetadataOutput) | 240 sampleNamesList = getSampleMetadata(xcmsSet=xset, sampleMetadataOutput=sampleMetadataOutput) |
221 getTICs(xcmsSet=xset, pdfname=ticspdf,rt="raw") | 241 getTICs(xcmsSet=xset, pdfname=ticspdf,rt="raw") |
222 getBPCs(xcmsSet=xset,rt="raw",pdfname=bicspdf) | 242 getBPCs(xcmsSet=xset,rt="raw",pdfname=bicspdf) |
223 } else if (thefunction == "retcor") { | 243 } else if (thefunction == "retcor") { |
244 cat("\t\tGET TIC GRAPH\n") | |
224 getTICs(xcmsSet=xset, pdfname=ticspdf,rt="corrected") | 245 getTICs(xcmsSet=xset, pdfname=ticspdf,rt="corrected") |
225 getBPCs(xcmsSet=xset,rt="corrected",pdfname=bicspdf) | 246 getBPCs(xcmsSet=xset,rt="corrected",pdfname=bicspdf) |
226 } | 247 } |
227 | 248 |
228 cat("\n\n") | 249 if (thefunction == "fillPeaks") { |
229 | 250 cat("\t\tGET THE PEAK LIST\n") |
251 getPeaklistW4M(xset,intval,convertRTMinute,numDigitsMZ,numDigitsRT,variableMetadataOutput,dataMatrixOutput) | |
252 } | |
253 | |
254 | |
255 cat("\n\n") | |
230 | 256 |
231 # ----- EXPORT ----- | 257 # ----- EXPORT ----- |
232 | 258 |
233 cat("\tXSET OBJECT INFO\n") | 259 cat("\tXSET OBJECT INFO\n") |
234 print(xset) | 260 print(xset) |
241 | 267 |
242 cat("\n\n") | 268 cat("\n\n") |
243 | 269 |
244 | 270 |
245 cat("\tDONE\n") | 271 cat("\tDONE\n") |
246 |