annotate lib_metams.r @ 1:708ab9928a70 draft

planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
author workflow4metabolomics
date Tue, 16 Jul 2019 09:57:10 -0400
parents b60dc620bd14
children 96debae917e4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
1 # lib_metams.r version 2.1.1
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
2 # R function for metaMS runGC under W4M
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
3 # author Yann GUITTON CNRS IRISA/LINA Idealg project 2014-2015
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
4 # author Yann GUITTON Oniris Laberca 2015-2017
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
5
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
6
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
7 #@author G. Le Corguille
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
8 # This function will
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
9 # - load the packages
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
10 # - display the sessionInfo
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
11 loadAndDisplayPackages <- function(pkgs) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
12 for(pkg in pkgs) suppressPackageStartupMessages( stopifnot( library(pkg, quietly=TRUE, logical.return=TRUE, character.only=TRUE)))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
13
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
14 sessioninfo = sessionInfo()
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
15 cat(sessioninfo$R.version$version.string,"\n")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
16 cat("Main packages:\n")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
17 for (pkg in names(sessioninfo$otherPkgs)) { cat(paste(pkg,packageVersion(pkg)),"\t") }; cat("\n")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
18 cat("Other loaded packages:\n")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
19 for (pkg in names(sessioninfo$loadedOnly)) { cat(paste(pkg,packageVersion(pkg)),"\t") }; cat("\n")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
20 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
21
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
22 #This function list the compatible files within the directory as xcms did
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
23 #@author Gildas Le Corguille lecorguille@sb-roscoff.fr ABiMS TEAM
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
24 getMSFiles <- function (directory) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
25 filepattern <- c("[Cc][Dd][Ff]", "[Nn][Cc]", "([Mm][Zz])?[Xx][Mm][Ll]","[Mm][Zz][Dd][Aa][Tt][Aa]", "[Mm][Zz][Mm][Ll]")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
26 filepattern <- paste(paste("\\.", filepattern, "$", sep=""),collapse="|")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
27 info <- file.info(directory)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
28 listed <- list.files(directory[info$isdir], pattern=filepattern,recursive=TRUE, full.names=TRUE)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
29 files <- c(directory[!info$isdir], listed)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
30 exists <- file.exists(files)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
31 files <- files[exists]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
32 return(files)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
33 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
34
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
35 # This function retrieve a xset like object
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
36 #@author Gildas Le Corguille lecorguille@sb-roscoff.fr
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
37 getxcmsSetObject <- function(xobject) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
38 # XCMS 1.x
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
39 if (class(xobject) == "xcmsSet")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
40 return (xobject)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
41 # XCMS 3.x
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
42 if (class(xobject) == "XCMSnExp") {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
43 # Get the legacy xcmsSet object
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
44 suppressWarnings(xset <- as(xobject, 'xcmsSet'))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
45 if (!is.null(xset@phenoData$sample_group))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
46 sampclass(xset) <- xset@phenoData$sample_group
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
47 else
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
48 sampclass(xset) <- "."
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
49 return (xset)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
50 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
51 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
52
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
53 #J.Saint-Vanne
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
54 #Function to correct the file names which can be written like "..alg8.mzData" and we just want "alg8"
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
55 getCorrectFileName <- function(peaktable,sampleMetadata){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
56
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
57 #Try to start for the first sample, avoid description of line with colnamesdontwant
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
58 i <- 1
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
59 while(!(sampleMetadata[1,1] %in% strsplit(colnames(peaktable)[i],"\\.")[[1]])) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
60 if(i < length(peaktable)) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
61 i <- i + 1
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
62 } else {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
63 break
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
64 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
65 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
66 #i now correspond to the first column with a sample
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
67 for(j in 1:(nrow(sampleMetadata))) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
68 col <- j + i-1 #minus 1 cause i is the good column to start and j start at 1
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
69 if(col <= length(colnames(peaktable))) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
70 newname <- gsub("(^.*)(\\..*$)","\\1",colnames(peaktable)[col])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
71 if(newname != sampleMetadata[j,1]){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
72 #Correction for 2 points starting the name (I don't know why they are here...)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
73 if(".." == gsub("(^\\.+)(.*)","\\1",newname)){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
74 newname <- sub("(^\\.+)(.*)","\\2",newname)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
75 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
76 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
77 colnames(peaktable)[col] <- newname
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
78 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
79 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
80 return(peaktable)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
81 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
82
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
83
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
84 #@author Gildas Le Corguille lecorguille@sb-roscoff.fr
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
85 # This function get the raw file path from the arguments
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
86 getRawfilePathFromArguments <- function(singlefile, zipfile, listArguments) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
87 if (!is.null(listArguments[["zipfile"]])) zipfile = listArguments[["zipfile"]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
88 if (!is.null(listArguments[["zipfilePositive"]])) zipfile = listArguments[["zipfilePositive"]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
89 if (!is.null(listArguments[["zipfileNegative"]])) zipfile = listArguments[["zipfileNegative"]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
90
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
91 if (!is.null(listArguments[["singlefile_galaxyPath"]])) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
92 singlefile_galaxyPaths = listArguments[["singlefile_galaxyPath"]];
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
93 singlefile_sampleNames = listArguments[["singlefile_sampleName"]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
94 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
95 if (!is.null(listArguments[["singlefile_galaxyPathPositive"]])) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
96 singlefile_galaxyPaths = listArguments[["singlefile_galaxyPathPositive"]];
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
97 singlefile_sampleNames = listArguments[["singlefile_sampleNamePositive"]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
98 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
99 if (!is.null(listArguments[["singlefile_galaxyPathNegative"]])) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
100 singlefile_galaxyPaths = listArguments[["singlefile_galaxyPathNegative"]];
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
101 singlefile_sampleNames = listArguments[["singlefile_sampleNameNegative"]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
102 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
103 if (exists("singlefile_galaxyPaths")){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
104 singlefile_galaxyPaths = unlist(strsplit(singlefile_galaxyPaths,","))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
105 singlefile_sampleNames = unlist(strsplit(singlefile_sampleNames,","))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
106
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
107 singlefile=NULL
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
108 for (singlefile_galaxyPath_i in seq(1:length(singlefile_galaxyPaths))) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
109 singlefile_galaxyPath=singlefile_galaxyPaths[singlefile_galaxyPath_i]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
110 singlefile_sampleName=singlefile_sampleNames[singlefile_galaxyPath_i]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
111 singlefile[[singlefile_sampleName]] = singlefile_galaxyPath
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
112 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
113 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
114 for (argument in c("zipfile","zipfilePositive","zipfileNegative","singlefile_galaxyPath","singlefile_sampleName","singlefile_galaxyPathPositive","singlefile_sampleNamePositive","singlefile_galaxyPathNegative","singlefile_sampleNameNegative")) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
115 listArguments[[argument]]=NULL
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
116 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
117 return(list(zipfile=zipfile, singlefile=singlefile, listArguments=listArguments))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
118 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
119
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
120
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
121 #@author Gildas Le Corguille lecorguille@sb-roscoff.fr
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
122 # This function retrieve the raw file in the working directory
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
123 # - if zipfile: unzip the file with its directory tree
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
124 # - if singlefiles: set symlink with the good filename
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
125 retrieveRawfileInTheWorkingDirectory <- function(singlefile, zipfile) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
126 if(!is.null(singlefile) && (length("singlefile")>0)) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
127 for (singlefile_sampleName in names(singlefile)) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
128 singlefile_galaxyPath = singlefile[[singlefile_sampleName]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
129 if(!file.exists(singlefile_galaxyPath)){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
130 error_message=paste("Cannot access the sample:",singlefile_sampleName,"located:",singlefile_galaxyPath,". Please, contact your administrator ... if you have one!")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
131 print(error_message); stop(error_message)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
132 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
133 file.symlink(singlefile_galaxyPath,singlefile_sampleName)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
134 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
135 directory = "."
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
136 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
137 if(!is.null(zipfile) && (zipfile!="")) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
138 if(!file.exists(zipfile)){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
139 error_message=paste("Cannot access the Zip file:",zipfile,". Please, contact your administrator ... if you have one!")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
140 print(error_message)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
141 stop(error_message)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
142 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
143
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
144 #list all file in the zip file
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
145 #zip_files=unzip(zipfile,list=T)[,"Name"]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
146
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
147 #unzip
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
148 suppressWarnings(unzip(zipfile, unzip="unzip"))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
149
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
150 #get the directory name
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
151 filesInZip=unzip(zipfile, list=T);
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
152 directories=unique(unlist(lapply(strsplit(filesInZip$Name,"/"), function(x) x[1])));
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
153 directories=directories[!(directories %in% c("__MACOSX")) & file.info(directories)$isdir]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
154 directory = "."
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
155 if (length(directories) == 1) directory = directories
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
156
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
157 cat("files_root_directory\t",directory,"\n")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
158 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
159 return (directory)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
160 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
161
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
162 ##ADDITIONS FROM Y. Guitton
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
163 getBPC <- function(file,rtcor=NULL, ...) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
164 object <- xcmsRaw(file)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
165 sel <- profRange(object, ...)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
166 cbind(if (is.null(rtcor)) object@scantime[sel$scanidx] else rtcor ,xcms:::colMax(object@env$profile[sel$massidx,sel$scanidx,drop=FALSE]))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
167 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
168
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
169 getBPC2s <- function (files, xset = NULL, pdfname="BPCs.pdf", rt = c("raw","corrected"), scanrange=NULL) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
170 require(xcms)
1
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
171
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
172 #Verification for cdf files
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
173 stop=FALSE
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
174 for(i in 1:length(files)){
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
175 extension <- unlist(strsplit(basename(files[i]),"\\."))[length(unlist(strsplit(basename(files[i]),"\\.")))]
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
176 if(extension == "CDF" || extension == "cdf"){
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
177 stop = TRUE
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
178 break
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
179 }
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
180 }
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
181 if(stop){
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
182 error_message <- "You have a CDF file and there is an issue to resolve on them for chromatograms.... !"
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
183 print(error_message)
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
184 stop(error_message)
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
185 }
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
186
0
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
187 #create sampleMetadata, get sampleMetadata and class
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
188 if(!is.null(xset)) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
189 #When files come from XCMS3 directly before metaMS
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
190 sampleMetadata <- xset@phenoData
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
191 } else {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
192 #When files come from a zip directory with raw files before metaMS
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
193 sampleMetadata<-xcms:::phenoDataFromPaths(files)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
194 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
195 class<-unique(sampleMetadata[,"class"]) #create phenoData like table
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
196 classnames<-vector("list",length(class))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
197 for (i in 1:length(class)){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
198 classnames[[i]]<-which( sampleMetadata[,"class"]==class[i])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
199 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
200
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
201 N <- dim(sampleMetadata)[1]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
202 TIC <- vector("list",N)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
203
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
204 for (j in 1:N) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
205 TIC[[j]] <- getBPC(files[j])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
206 #good for raw
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
207 # seems strange for corrected
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
208 #errors if scanrange used in xcmsSetgeneration
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
209 if (!is.null(xcmsSet) && rt == "corrected"){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
210 rtcor <- xcmsSet@rt$corrected[[j]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
211 }else{
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
212 rtcor <- NULL
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
213 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
214 TIC[[j]] <- getBPC(files[j],rtcor=rtcor)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
215 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
216
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
217 pdf(pdfname,w=16,h=10)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
218 cols <- rainbow(N)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
219 lty = 1:N
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
220 pch = 1:N
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
221 #search for max x and max y in BPCs
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
222 xlim = range(sapply(TIC, function(x) range(x[,1])))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
223 ylim = range(sapply(TIC, function(x) range(x[,2])))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
224 ylim = c(-ylim[2], ylim[2])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
225
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
226 ##plot start
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
227 if (length(class)>2){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
228 for (k in 1:(length(class)-1)){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
229 for (l in (k+1):length(class)){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
230 cat(paste(class[k],"vs",class[l],sep=" ","\n"))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
231 plot(0, 0, type="n", xlim = xlim/60, ylim = ylim, main = paste("Base Peak Chromatograms \n","BPCs_",class[k]," vs ",class[l], sep=""), xlab = "Retention Time (min)", ylab = "BPC")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
232 colvect<-NULL
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
233 for (j in 1:length(classnames[[k]])) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
234 tic <- TIC[[classnames[[k]][j]]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
235 # points(tic[,1]/60, tic[,2], col = cols[i], pch = pch[i], type="l")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
236 points(tic[,1]/60, tic[,2], col = cols[classnames[[k]][j]], pch = pch[classnames[[k]][j]], type="l")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
237 colvect<-append(colvect,cols[classnames[[k]][j]])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
238 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
239 for (j in 1:length(classnames[[l]])) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
240 # i=class2names[j]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
241 tic <- TIC[[classnames[[l]][j]]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
242 points(tic[,1]/60, -tic[,2], col = cols[classnames[[l]][j]], pch = pch[classnames[[l]][j]], type="l")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
243 colvect<-append(colvect,cols[classnames[[l]][j]])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
244 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
245 legend("topright",paste(gsub("(^.+)\\..*$","\\1",basename(files[c(classnames[[k]],classnames[[l]])]))), col = colvect, lty = lty, pch = pch)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
246 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
247 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
248 }#end if length >2
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
249
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
250 if (length(class)==2){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
251 k=1
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
252 l=2
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
253 colvect<-NULL
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
254 plot(0, 0, type="n", xlim = xlim/60, ylim = ylim, main = paste("Base Peak Chromatograms \n","BPCs_",class[k],"vs",class[l], sep=""), xlab = "Retention Time (min)", ylab = "BPC")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
255
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
256 for (j in 1:length(classnames[[k]])) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
257 tic <- TIC[[classnames[[k]][j]]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
258 # points(tic[,1]/60, tic[,2], col = cols[i], pch = pch[i], type="l")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
259 points(tic[,1]/60, tic[,2], col = cols[classnames[[k]][j]], pch = pch[classnames[[k]][j]], type="l")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
260 colvect<-append(colvect,cols[classnames[[k]][j]])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
261 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
262 for (j in 1:length(classnames[[l]])) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
263 # i=class2names[j]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
264 tic <- TIC[[classnames[[l]][j]]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
265 points(tic[,1]/60, -tic[,2], col = cols[classnames[[l]][j]], pch = pch[classnames[[l]][j]], type="l")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
266 colvect<-append(colvect,cols[classnames[[l]][j]])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
267 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
268 legend("topright",paste(gsub("(^.+)\\..*$","\\1",basename(files[c(classnames[[k]],classnames[[l]])]))), col = colvect, lty = lty, pch = pch)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
269 }#end length ==2
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
270
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
271 if (length(class)==1){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
272 k=1
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
273 ylim = range(sapply(TIC, function(x) range(x[,2])))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
274 colvect<-NULL
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
275 plot(0, 0, type="n", xlim = xlim/60, ylim = ylim, main = paste("Base Peak Chromatograms \n","BPCs_",class[k], sep=""), xlab = "Retention Time (min)", ylab = "BPC")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
276
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
277 for (j in 1:length(classnames[[k]])) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
278 tic <- TIC[[classnames[[k]][j]]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
279 # points(tic[,1]/60, tic[,2], col = cols[i], pch = pch[i], type="l")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
280 points(tic[,1]/60, tic[,2], col = cols[classnames[[k]][j]], pch = pch[classnames[[k]][j]], type="l")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
281 colvect<-append(colvect,cols[classnames[[k]][j]])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
282 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
283 legend("topright",paste(gsub("(^.+)\\..*$","\\1",basename(files[c(classnames[[k]])]))), col = colvect, lty = lty, pch = pch)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
284 }#end length ==1
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
285 dev.off()
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
286 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
287
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
288 getTIC <- function(file,rtcor=NULL) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
289 object <- xcmsRaw(file)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
290 cbind(if (is.null(rtcor)) object@scantime else rtcor, rawEIC(object,mzrange=range(object@env$mz))$intensity)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
291 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
292
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
293 ## overlay TIC from all files in current folder or from xcmsSet, create pdf
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
294 getTIC2s <- function(files, xset=NULL, pdfname="TICs.pdf", rt=c("raw","corrected")) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
295 require(xcms)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
296
1
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
297 #Verification for cdf files
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
298 stop=FALSE
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
299 for(i in 1:length(files)){
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
300 extension <- unlist(strsplit(basename(files[i]),"\\."))[length(unlist(strsplit(basename(files[i]),"\\.")))]
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
301 if(extension == "CDF" || extension == "cdf"){
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
302 stop = TRUE
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
303 break
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
304 }
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
305 }
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
306 if(stop){
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
307 error_message <- "You have a CDF file and there is an issue to resolve on them for chromatograms.... !"
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
308 print(error_message)
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
309 stop(error_message)
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
310 }
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
311
0
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
312 #create sampleMetadata, get sampleMetadata and class
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
313 if(!is.null(xset)){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
314 #When files come from XCMS3 before metaMS treatment
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
315 sampleMetadata<-xset@phenoData
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
316 } else {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
317 #When files come from a zip directory with raw files before metaMS
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
318 sampleMetadata<-xcms:::phenoDataFromPaths(files)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
319 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
320 class<-as.vector(levels(sampleMetadata[,"class"])) #create phenoData like table
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
321 classnames<-vector("list",length(class))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
322 for (i in 1:length(class)){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
323 classnames[[i]]<-which( sampleMetadata[,"class"]==class[i])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
324 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
325
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
326 N <- dim(sampleMetadata)[1]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
327 TIC <- vector("list",N)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
328
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
329 for (i in 1:N) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
330 cat(files[i],"\n")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
331 if (!is.null(xcmsSet) && rt == "corrected")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
332 rtcor <- xcmsSet@rt$corrected[[i]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
333 else
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
334 rtcor <- NULL
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
335 TIC[[i]] <- getTIC(files[i],rtcor=rtcor)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
336 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
337
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
338 pdf(pdfname,w=16,h=10)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
339 cols <- rainbow(N)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
340 lty = 1:N
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
341 pch = 1:N
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
342 #search for max x and max y in TICs
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
343 xlim = range(sapply(TIC, function(x) range(x[,1])))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
344 ylim = range(sapply(TIC, function(x) range(x[,2])))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
345 ylim = c(-ylim[2], ylim[2])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
346
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
347 ##plot start
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
348 if (length(class)>2){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
349 for (k in 1:(length(class)-1)){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
350 for (l in (k+1):length(class)){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
351 print(paste(class[k],"vs",class[l],sep=" "))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
352 plot(0, 0, type="n", xlim = xlim/60, ylim = ylim, main = paste("Total Ion Chromatograms \n","TICs_",class[k]," vs ",class[l], sep=""), xlab = "Retention Time (min)", ylab = "TIC")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
353 colvect<-NULL
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
354 for (j in 1:length(classnames[[k]])) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
355 tic <- TIC[[classnames[[k]][j]]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
356 # points(tic[,1]/60, tic[,2], col = cols[i], pch = pch[i], type="l")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
357 points(tic[,1]/60, tic[,2], col = cols[classnames[[k]][j]], pch = pch[classnames[[k]][j]], type="l")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
358 colvect<-append(colvect,cols[classnames[[k]][j]])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
359 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
360 for (j in 1:length(classnames[[l]])) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
361 # i=class2names[j]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
362 tic <- TIC[[classnames[[l]][j]]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
363 points(tic[,1]/60, -tic[,2], col = cols[classnames[[l]][j]], pch = pch[classnames[[l]][j]], type="l")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
364 colvect<-append(colvect,cols[classnames[[l]][j]])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
365 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
366 legend("topright",paste(gsub("(^.+)\\..*$","\\1",basename(files[c(classnames[[k]],classnames[[l]])]))), col = colvect, lty = lty, pch = pch)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
367 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
368 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
369 }#end if length >2
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
370
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
371 if (length(class)==2){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
372 k=1
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
373 l=2
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
374 plot(0, 0, type="n", xlim = xlim/60, ylim = ylim, main = paste("Total Ion Chromatograms \n","TICs_",class[k],"vs",class[l], sep=""), xlab = "Retention Time (min)", ylab = "TIC")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
375 colvect<-NULL
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
376 for (j in 1:length(classnames[[k]])) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
377 tic <- TIC[[classnames[[k]][j]]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
378 # points(tic[,1]/60, tic[,2], col = cols[i], pch = pch[i], type="l")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
379 points(tic[,1]/60, tic[,2], col = cols[classnames[[k]][j]], pch = pch[classnames[[k]][j]], type="l")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
380 colvect<-append(colvect,cols[classnames[[k]][j]])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
381 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
382 for (j in 1:length(classnames[[l]])) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
383 # i=class2names[j]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
384 tic <- TIC[[classnames[[l]][j]]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
385 points(tic[,1]/60, -tic[,2], col = cols[classnames[[l]][j]], pch = pch[classnames[[l]][j]], type="l")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
386 colvect<-append(colvect,cols[classnames[[l]][j]])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
387 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
388 legend("topright",paste(gsub("(^.+)\\..*$","\\1",basename(files[c(classnames[[k]],classnames[[l]])]))), col = colvect, lty = lty, pch = pch)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
389 }#end length ==2
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
390
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
391 if (length(class)==1){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
392 k=1
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
393 ylim = range(sapply(TIC, function(x) range(x[,2])))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
394 plot(0, 0, type="n", xlim = xlim/60, ylim = ylim, main = paste("Total Ion Chromatograms \n","TICs_",class[k], sep=""), xlab = "Retention Time (min)", ylab = "TIC")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
395 colvect<-NULL
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
396 for (j in 1:length(classnames[[k]])) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
397 tic <- TIC[[classnames[[k]][j]]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
398 # points(tic[,1]/60, tic[,2], col = cols[i], pch = pch[i], type="l")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
399 points(tic[,1]/60, tic[,2], col = cols[classnames[[k]][j]], pch = pch[classnames[[k]][j]], type="l")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
400 colvect<-append(colvect,cols[classnames[[k]][j]])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
401 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
402 legend("topright",paste(gsub("(^.+)\\..*$","\\1",basename(files[c(classnames[[k]])]))), col = colvect, lty = lty, pch = pch)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
403 }#end length ==1
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
404 dev.off()
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
405 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
406
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
407
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
408 #Update by J.Saint-Vanne
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
409 ##addition for quality control of peak picking
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
410 #metaMS EIC and pspectra plotting option
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
411 #version 20190520
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
412 #only for Galaxy
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
413 plotUnknowns<-function(resGC, unkn="", DB=NULL, fileFrom=NULL){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
414
1
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
415 #Verification for cdf files
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
416 stop=FALSE
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
417 for(i in 1:length(names(resGC$annotation))){
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
418 extension <- unlist(strsplit(basename(names(resGC$annotation)[i]),"\\."))[length(unlist(strsplit(basename(names(resGC$annotation)[i]),"\\.")))]
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
419 if(extension == "CDF" || extension == "cdf"){
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
420 stop = TRUE
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
421 break
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
422 }
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
423 }
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
424 if(stop){
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
425 error_message <- "You have a CDF file and there is an issue to resolve on them for chromatograms.... !"
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
426 print(error_message)
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
427 stop(error_message)
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
428 }
708ab9928a70 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 11bb57ea2b95649ae60bd451cb21432d117a93e2
workflow4metabolomics
parents: 0
diff changeset
429
0
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
430 ##Annotation table each value is a pcgrp associated to the unknown
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
431 ##NOTE pcgrp index are different between xcmsSet and resGC due to filtering steps in metaMS
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
432 ##R. Wehrens give me some clues on that and we found a correction
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
433
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
434 #correction of annotation matrix due to pcgrp removal by quality check in runGCresult
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
435 #matrix of correspondance between an@pspectra and filtered pspectra from runGC
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
436 #Select only pspectra which correpond to them select in metaMS
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
437 # col1 = filtered spectra from runGC and col2 = an@spectra
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
438 allPCGRPs <-lapply(1:length(resGC$xset),
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
439 function(i) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
440 an <- resGC$xset[[i]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
441 huhn <- an@pspectra[which(sapply(an@pspectra, length) >=
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
442 metaSetting(resGC$settings,
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
443 "DBconstruction.minfeat"))]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
444 matCORR<-cbind(1:length(huhn), match(huhn, an@pspectra))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
445 })
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
446 #Build a new annotation list with sampnames and pseudospectra number from xset
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
447 helpannotation <- list()
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
448 for(j in 1:length(resGC$xset)){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
449 helpannotation[[j]] <- resGC$annotation[[j]][1:2]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
450 pspvector <- vector()
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
451 for(i in 1: nrow(helpannotation[[j]])){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
452 #Find corresponding pspec
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
453 psplink <- allPCGRPs[[j]][match(helpannotation[[j]][i,1],allPCGRPs[[j]]),2]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
454 pspvector <- c(pspvector,psplink)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
455 #Change the annotation column into sampname column
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
456 if(helpannotation[[j]][i,2] < 0){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
457 #It's an unknown
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
458 new_name <- paste("Unknown",abs(as.integer(helpannotation[[j]][i,2])))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
459 helpannotation[[j]][i,2] <- new_name
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
460 }else{
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
461 #It has been found in local database
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
462 for(k in 1:length(DB)){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
463 if(helpannotation[[j]][i,2] == k){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
464 helpannotation[[j]][i,2] <- DB[[k]]$Name
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
465 break
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
466 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
467 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
468 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
469 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
470 helpannotation[[j]] <- cbind(helpannotation[[j]],pspvector)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
471 names(helpannotation)[j] <- names(resGC$annotation[j])
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
472 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
473 peaktable <- resGC$PeakTable
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
474
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
475 par (mar=c(5, 4, 4, 2) + 0.1)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
476 #For each unknown
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
477 for (l in 1:length(unkn)){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
478 #recordPlot
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
479 perpage=3 #if change change layout also!
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
480 dev.new(width=21/2.54, height=29.7/2.54, file=paste("Unknown_",unkn[l],".pdf", sep="")) #A4 pdf
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
481 # par(mfrow=c(perpage,2))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
482 layout(matrix(c(1,1,2,3,4,4,5,6,7,7,8,9), 6, 2, byrow = TRUE), widths=rep(c(1,1),perpage), heights=rep(c(1,5),perpage))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
483 # layout.show(6)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
484 oma.saved <- par("oma")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
485 par(oma = rep.int(0, 4))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
486 par(oma = oma.saved)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
487 o.par <- par(mar = rep.int(0, 4))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
488 on.exit(par(o.par))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
489 #For each sample
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
490 for (c in 1:length(resGC$xset)) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
491 #get sample name
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
492 sampname<-basename(resGC$xset[[c]]@xcmsSet@filepaths)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
493 #remove .cdf, .mzXML filepattern
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
494 filepattern <- c("[Cc][Dd][Ff]", "[Nn][Cc]", "([Mm][Zz])?[Xx][Mm][Ll]",
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
495 "[Mm][Zz][Dd][Aa][Tt][Aa]", "[Mm][Zz][Mm][Ll]")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
496 filepattern <- paste(paste("\\.", filepattern, "$", sep = ""), collapse = "|")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
497 sampname<-gsub(filepattern, "",sampname)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
498 title1<-paste(peaktable[unkn[l],1],"from",sampname, sep = " ")
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
499 an<-resGC$xset[[c]]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
500 if(fileFrom == "zipfile") {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
501 an@xcmsSet@filepaths <- paste0("./",an@xcmsSet@phenoData[,"class"],"/",basename(an@xcmsSet@filepaths))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
502 }#else {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
503 #print(an@xcmsSet@filepaths)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
504 #an@xcmsSet@filepaths <- paste0("./",basename(an@xcmsSet@filepaths))
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
505 #}
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
506 #Find the good annotation for this sample
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
507 for(a in 1:length(helpannotation)){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
508 if(gsub(filepattern, "", names(helpannotation)[a]) == paste0("./",sampname)){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
509 #Find the unkn or the matched std in this sample
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
510 findunkn <- FALSE
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
511 for(r in 1:nrow(helpannotation[[a]])){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
512 if(helpannotation[[a]][r,"annotation"] == peaktable[unkn[l],1]){
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
513 findunkn <- TRUE
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
514 pcgrp <- helpannotation[[a]][r,"pspvector"]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
515 par (mar=c(0, 0, 0, 0) + 0.1)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
516 #Write title
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
517 plot.new()
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
518 box()
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
519 text(0.5, 0.5, title1, cex=2)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
520 par (mar=c(3, 2.5, 3, 1.5) + 0.1)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
521 #Window for EIC
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
522 plotEICs(an, pspec=pcgrp, maxlabel=2)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
523 #Window for pseudospectra
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
524 plotPsSpectrum(an, pspec=pcgrp, maxlabel=2)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
525 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
526 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
527 if(!findunkn) {
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
528 par (mar=c(0, 0, 0, 0) + 0.1)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
529 #Write title
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
530 plot.new()
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
531 box()
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
532 text(0.5, 0.5, title1, cex=2)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
533 #Window for EIC
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
534 plot.new()
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
535 box()
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
536 text(0.5, 0.5, "NOT FOUND", cex=2)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
537 #Window for pseudospectra
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
538 plot.new()
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
539 box()
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
540 text(0.5, 0.5, "NOT FOUND", cex=2)
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
541 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
542 break
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
543 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
544 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
545 }
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
546 graphics.off()
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
547 }#end for unkn[l]
b60dc620bd14 planemo upload for repository https://github.com/workflow4metabolomics/metaMS commit 174a1713024f246c1485cbd75218577e89353522
workflow4metabolomics
parents:
diff changeset
548 }#end function