annotate lib_metams.r @ 5:b8d4129dd2a6 draft

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