Mercurial > repos > lecorguille > xcms_group
annotate lib.r @ 11:9e45e1c404a4 draft
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit c12284c89d941da18f30b2666a64434ce1073cea
author | lecorguille |
---|---|
date | Fri, 19 May 2017 09:55:06 -0400 |
parents | c81275aee959 |
children | 833d2c821d9c |
rev | line source |
---|---|
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
1 #Authors ABiMS TEAM |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
2 #Lib.r for Galaxy Workflow4Metabolomics xcms tools |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
3 # |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
4 #version 2.4: lecorguille |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
5 # add getPeaklistW4M |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
6 #version 2.3: yguitton |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
7 # correction for empty PDF when only 1 class |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
8 #version 2.2 |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
9 # correct bug in Base Peak Chromatogram (BPC) option, not only TIC when scanrange used in xcmsSet |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
10 # Note if scanrange is used a warning is prompted in R console but do not stop PDF generation |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
11 #version 2.1: yguitton |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
12 # Modifications made by Guitton Yann |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
13 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
14 |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
15 #@author G. Le Corguille |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
16 #This function convert if it is required the Retention Time in minutes |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
17 RTSecondToMinute <- function(variableMetadata, convertRTMinute) { |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
18 if (convertRTMinute){ |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
19 #converting the retention times (seconds) into minutes |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
20 print("converting the retention times into minutes in the variableMetadata") |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
21 variableMetadata[,"rt"]=variableMetadata[,"rt"]/60 |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
22 variableMetadata[,"rtmin"]=variableMetadata[,"rtmin"]/60 |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
23 variableMetadata[,"rtmax"]=variableMetadata[,"rtmax"]/60 |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
24 } |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
25 return (variableMetadata) |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
26 } |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
27 |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
28 #@author G. Le Corguille |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
29 #This function format ions identifiers |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
30 formatIonIdentifiers <- function(variableMetadata, numDigitsRT=0, numDigitsMZ=0) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
31 splitDeco = strsplit(as.character(variableMetadata$name),"_") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
32 idsDeco = sapply(splitDeco, function(x) { deco=unlist(x)[2]; if (is.na(deco)) return ("") else return(paste0("_",deco)) }) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
33 namecustom = make.unique(paste0("M",round(variableMetadata[,"mz"],numDigitsMZ),"T",round(variableMetadata[,"rt"],numDigitsRT),idsDeco)) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
34 variableMetadata=cbind(name=variableMetadata$name, namecustom=namecustom, variableMetadata[,!(colnames(variableMetadata) %in% c("name"))]) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
35 return(variableMetadata) |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
36 } |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
37 |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
38 #@author G. Le Corguille |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
39 # value: intensity values to be used into, maxo or intb |
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
40 getPeaklistW4M <- function(xset, intval="into",convertRTMinute=F,numDigitsMZ=4,numDigitsRT=0,variableMetadataOutput,dataMatrixOutput) { |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
41 variableMetadata_dataMatrix = peakTable(xset, method="medret", value=intval) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
42 variableMetadata_dataMatrix = cbind(name=groupnames(xset),variableMetadata_dataMatrix) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
43 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
44 dataMatrix = variableMetadata_dataMatrix[,(make.names(colnames(variableMetadata_dataMatrix)) %in% c("name", make.names(sampnames(xset))))] |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
45 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
46 variableMetadata = variableMetadata_dataMatrix[,!(make.names(colnames(variableMetadata_dataMatrix)) %in% c(make.names(sampnames(xset))))] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
47 variableMetadata = RTSecondToMinute(variableMetadata, convertRTMinute) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
48 variableMetadata = formatIonIdentifiers(variableMetadata, numDigitsRT=numDigitsRT, numDigitsMZ=numDigitsMZ) |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
49 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
50 write.table(variableMetadata, file=variableMetadataOutput,sep="\t",quote=F,row.names=F) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
51 write.table(dataMatrix, file=dataMatrixOutput,sep="\t",quote=F,row.names=F) |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
52 } |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
53 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
54 #@author Y. Guitton |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
55 getBPC <- function(file,rtcor=NULL, ...) { |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
56 object <- xcmsRaw(file) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
57 sel <- profRange(object, ...) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
58 cbind(if (is.null(rtcor)) object@scantime[sel$scanidx] else rtcor ,xcms:::colMax(object@env$profile[sel$massidx,sel$scanidx,drop=FALSE])) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
59 #plotChrom(xcmsRaw(file), base=T) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
60 } |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
61 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
62 #@author Y. Guitton |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
63 getBPCs <- function (xcmsSet=NULL, pdfname="BPCs.pdf",rt=c("raw","corrected"), scanrange=NULL) { |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
64 cat("Creating BIC pdf...\n") |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
65 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
66 if (is.null(xcmsSet)) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
67 cat("Enter an xcmsSet \n") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
68 stop() |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
69 } else { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
70 files <- filepaths(xcmsSet) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
71 } |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
72 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
73 phenoDataClass<-as.vector(levels(xcmsSet@phenoData[,1])) #sometime phenoData have more than 1 column use first as class |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
74 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
75 classnames<-vector("list",length(phenoDataClass)) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
76 for (i in 1:length(phenoDataClass)){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
77 classnames[[i]]<-which( xcmsSet@phenoData[,1]==phenoDataClass[i]) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
78 } |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
79 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
80 N <- dim(phenoData(xcmsSet))[1] |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
81 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
82 TIC <- vector("list",N) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
83 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
84 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
85 for (j in 1:N) { |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
86 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
87 TIC[[j]] <- getBPC(files[j]) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
88 #good for raw |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
89 # seems strange for corrected |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
90 #errors if scanrange used in xcmsSetgeneration |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
91 if (!is.null(xcmsSet) && rt == "corrected") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
92 rtcor <- xcmsSet@rt$corrected[[j]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
93 else |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
94 rtcor <- NULL |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
95 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
96 TIC[[j]] <- getBPC(files[j],rtcor=rtcor) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
97 # TIC[[j]][,1]<-rtcor |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
98 } |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
99 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
100 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
101 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
102 pdf(pdfname,w=16,h=10) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
103 cols <- rainbow(N) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
104 lty = 1:N |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
105 pch = 1:N |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
106 #search for max x and max y in BPCs |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
107 xlim = range(sapply(TIC, function(x) range(x[,1]))) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
108 ylim = range(sapply(TIC, function(x) range(x[,2]))) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
109 ylim = c(-ylim[2], ylim[2]) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
110 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
111 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
112 ##plot start |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
113 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
114 if (length(phenoDataClass)>2){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
115 for (k in 1:(length(phenoDataClass)-1)){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
116 for (l in (k+1):length(phenoDataClass)){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
117 #print(paste(phenoDataClass[k],"vs",phenoDataClass[l],sep=" ")) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
118 plot(0, 0, type="n", xlim = xlim/60, ylim = ylim, main = paste("Base Peak Chromatograms \n","BPCs_",phenoDataClass[k]," vs ",phenoDataClass[l], sep=""), xlab = "Retention Time (min)", ylab = "BPC") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
119 colvect<-NULL |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
120 for (j in 1:length(classnames[[k]])) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
121 tic <- TIC[[classnames[[k]][j]]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
122 # points(tic[,1]/60, tic[,2], col = cols[i], pch = pch[i], type="l") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
123 points(tic[,1]/60, tic[,2], col = cols[classnames[[k]][j]], pch = pch[classnames[[k]][j]], type="l") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
124 colvect<-append(colvect,cols[classnames[[k]][j]]) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
125 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
126 for (j in 1:length(classnames[[l]])) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
127 # i=class2names[j] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
128 tic <- TIC[[classnames[[l]][j]]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
129 points(tic[,1]/60, -tic[,2], col = cols[classnames[[l]][j]], pch = pch[classnames[[l]][j]], type="l") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
130 colvect<-append(colvect,cols[classnames[[l]][j]]) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
131 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
132 legend("topright",paste(basename(files[c(classnames[[k]],classnames[[l]])])), col = colvect, lty = lty, pch = pch) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
133 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
134 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
135 }#end if length >2 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
136 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
137 if (length(phenoDataClass)==2){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
138 k=1 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
139 l=2 |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
140 colvect<-NULL |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
141 plot(0, 0, type="n", xlim = xlim/60, ylim = ylim, main = paste("Base Peak Chromatograms \n","BPCs_",phenoDataClass[k],"vs",phenoDataClass[l], sep=""), xlab = "Retention Time (min)", ylab = "BPC") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
142 |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
143 for (j in 1:length(classnames[[k]])) { |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
144 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
145 tic <- TIC[[classnames[[k]][j]]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
146 # points(tic[,1]/60, tic[,2], col = cols[i], pch = pch[i], type="l") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
147 points(tic[,1]/60, tic[,2], col = cols[classnames[[k]][j]], pch = pch[classnames[[k]][j]], type="l") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
148 colvect<-append(colvect,cols[classnames[[k]][j]]) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
149 } |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
150 for (j in 1:length(classnames[[l]])) { |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
151 # i=class2names[j] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
152 tic <- TIC[[classnames[[l]][j]]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
153 points(tic[,1]/60, -tic[,2], col = cols[classnames[[l]][j]], pch = pch[classnames[[l]][j]], type="l") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
154 colvect<-append(colvect,cols[classnames[[l]][j]]) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
155 } |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
156 legend("topright",paste(basename(files[c(classnames[[k]],classnames[[l]])])), col = colvect, lty = lty, pch = pch) |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
157 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
158 }#end length ==2 |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
159 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
160 #case where only one class |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
161 if (length(phenoDataClass)==1){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
162 k=1 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
163 ylim = range(sapply(TIC, function(x) range(x[,2]))) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
164 colvect<-NULL |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
165 plot(0, 0, type="n", xlim = xlim/60, ylim = ylim, main = paste("Base Peak Chromatograms \n","BPCs_",phenoDataClass[k], sep=""), xlab = "Retention Time (min)", ylab = "BPC") |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
166 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
167 for (j in 1:length(classnames[[k]])) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
168 tic <- TIC[[classnames[[k]][j]]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
169 # points(tic[,1]/60, tic[,2], col = cols[i], pch = pch[i], type="l") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
170 points(tic[,1]/60, tic[,2], col = cols[classnames[[k]][j]], pch = pch[classnames[[k]][j]], type="l") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
171 colvect<-append(colvect,cols[classnames[[k]][j]]) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
172 } |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
173 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
174 legend("topright",paste(basename(files[c(classnames[[k]])])), col = colvect, lty = lty, pch = pch) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
175 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
176 }#end length ==1 |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
177 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
178 dev.off() #pdf(pdfname,w=16,h=10) |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
179 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
180 invisible(TIC) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
181 } |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
182 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
183 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
184 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
185 #@author Y. Guitton |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
186 getTIC <- function(file,rtcor=NULL) { |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
187 object <- xcmsRaw(file) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
188 cbind(if (is.null(rtcor)) object@scantime else rtcor, rawEIC(object,mzrange=range(object@env$mz))$intensity) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
189 } |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
190 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
191 ## |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
192 ## overlay TIC from all files in current folder or from xcmsSet, create pdf |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
193 ## |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
194 #@author Y. Guitton |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
195 getTICs <- function(xcmsSet=NULL,files=NULL, pdfname="TICs.pdf",rt=c("raw","corrected")) { |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
196 cat("Creating TIC pdf...\n") |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
197 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
198 if (is.null(xcmsSet)) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
199 filepattern <- c("[Cc][Dd][Ff]", "[Nn][Cc]", "([Mm][Zz])?[Xx][Mm][Ll]", "[Mm][Zz][Dd][Aa][Tt][Aa]", "[Mm][Zz][Mm][Ll]") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
200 filepattern <- paste(paste("\\.", filepattern, "$", sep = ""), collapse = "|") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
201 if (is.null(files)) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
202 files <- getwd() |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
203 info <- file.info(files) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
204 listed <- list.files(files[info$isdir], pattern = filepattern, recursive = TRUE, full.names = TRUE) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
205 files <- c(files[!info$isdir], listed) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
206 } else { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
207 files <- filepaths(xcmsSet) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
208 } |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
209 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
210 phenoDataClass<-as.vector(levels(xcmsSet@phenoData[,1])) #sometime phenoData have more than 1 column use first as class |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
211 classnames<-vector("list",length(phenoDataClass)) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
212 for (i in 1:length(phenoDataClass)){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
213 classnames[[i]]<-which( xcmsSet@phenoData[,1]==phenoDataClass[i]) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
214 } |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
215 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
216 N <- length(files) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
217 TIC <- vector("list",N) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
218 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
219 for (i in 1:N) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
220 if (!is.null(xcmsSet) && rt == "corrected") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
221 rtcor <- xcmsSet@rt$corrected[[i]] else |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
222 rtcor <- NULL |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
223 TIC[[i]] <- getTIC(files[i],rtcor=rtcor) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
224 } |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
225 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
226 pdf(pdfname,w=16,h=10) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
227 cols <- rainbow(N) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
228 lty = 1:N |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
229 pch = 1:N |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
230 #search for max x and max y in TICs |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
231 xlim = range(sapply(TIC, function(x) range(x[,1]))) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
232 ylim = range(sapply(TIC, function(x) range(x[,2]))) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
233 ylim = c(-ylim[2], ylim[2]) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
234 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
235 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
236 ##plot start |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
237 if (length(phenoDataClass)>2){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
238 for (k in 1:(length(phenoDataClass)-1)){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
239 for (l in (k+1):length(phenoDataClass)){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
240 #print(paste(phenoDataClass[k],"vs",phenoDataClass[l],sep=" ")) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
241 plot(0, 0, type="n", xlim = xlim/60, ylim = ylim, main = paste("Total Ion Chromatograms \n","TICs_",phenoDataClass[k]," vs ",phenoDataClass[l], sep=""), xlab = "Retention Time (min)", ylab = "TIC") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
242 colvect<-NULL |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
243 for (j in 1:length(classnames[[k]])) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
244 tic <- TIC[[classnames[[k]][j]]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
245 # points(tic[,1]/60, tic[,2], col = cols[i], pch = pch[i], type="l") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
246 points(tic[,1]/60, tic[,2], col = cols[classnames[[k]][j]], pch = pch[classnames[[k]][j]], type="l") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
247 colvect<-append(colvect,cols[classnames[[k]][j]]) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
248 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
249 for (j in 1:length(classnames[[l]])) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
250 # i=class2names[j] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
251 tic <- TIC[[classnames[[l]][j]]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
252 points(tic[,1]/60, -tic[,2], col = cols[classnames[[l]][j]], pch = pch[classnames[[l]][j]], type="l") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
253 colvect<-append(colvect,cols[classnames[[l]][j]]) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
254 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
255 legend("topright",paste(basename(files[c(classnames[[k]],classnames[[l]])])), col = colvect, lty = lty, pch = pch) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
256 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
257 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
258 }#end if length >2 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
259 if (length(phenoDataClass)==2){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
260 k=1 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
261 l=2 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
262 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
263 plot(0, 0, type="n", xlim = xlim/60, ylim = ylim, main = paste("Total Ion Chromatograms \n","TICs_",phenoDataClass[k],"vs",phenoDataClass[l], sep=""), xlab = "Retention Time (min)", ylab = "TIC") |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
264 colvect<-NULL |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
265 for (j in 1:length(classnames[[k]])) { |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
266 tic <- TIC[[classnames[[k]][j]]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
267 # points(tic[,1]/60, tic[,2], col = cols[i], pch = pch[i], type="l") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
268 points(tic[,1]/60, tic[,2], col = cols[classnames[[k]][j]], pch = pch[classnames[[k]][j]], type="l") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
269 colvect<-append(colvect,cols[classnames[[k]][j]]) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
270 } |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
271 for (j in 1:length(classnames[[l]])) { |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
272 # i=class2names[j] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
273 tic <- TIC[[classnames[[l]][j]]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
274 points(tic[,1]/60, -tic[,2], col = cols[classnames[[l]][j]], pch = pch[classnames[[l]][j]], type="l") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
275 colvect<-append(colvect,cols[classnames[[l]][j]]) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
276 } |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
277 legend("topright",paste(basename(files[c(classnames[[k]],classnames[[l]])])), col = colvect, lty = lty, pch = pch) |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
278 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
279 }#end length ==2 |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
280 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
281 #case where only one class |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
282 if (length(phenoDataClass)==1){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
283 k=1 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
284 ylim = range(sapply(TIC, function(x) range(x[,2]))) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
285 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
286 plot(0, 0, type="n", xlim = xlim/60, ylim = ylim, main = paste("Total Ion Chromatograms \n","TICs_",phenoDataClass[k], sep=""), xlab = "Retention Time (min)", ylab = "TIC") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
287 colvect<-NULL |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
288 for (j in 1:length(classnames[[k]])) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
289 tic <- TIC[[classnames[[k]][j]]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
290 # points(tic[,1]/60, tic[,2], col = cols[i], pch = pch[i], type="l") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
291 points(tic[,1]/60, tic[,2], col = cols[classnames[[k]][j]], pch = pch[classnames[[k]][j]], type="l") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
292 colvect<-append(colvect,cols[classnames[[k]][j]]) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
293 } |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
294 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
295 legend("topright",paste(basename(files[c(classnames[[k]])])), col = colvect, lty = lty, pch = pch) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
296 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
297 }#end length ==1 |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
298 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
299 dev.off() #pdf(pdfname,w=16,h=10) |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
300 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
301 invisible(TIC) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
302 } |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
303 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
304 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
305 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
306 ## |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
307 ## Get the polarities from all the samples of a condition |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
308 #@author Misharl Monsoor misharl.monsoor@sb-roscoff.fr ABiMS TEAM |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
309 #@author Gildas Le Corguille lecorguille@sb-roscoff.fr ABiMS TEAM |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
310 getSampleMetadata <- function(xcmsSet=NULL, sampleMetadataOutput="sampleMetadata.tsv") { |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
311 cat("Creating the sampleMetadata file...\n") |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
312 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
313 #Create the sampleMetada dataframe |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
314 sampleMetadata=xset@phenoData |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
315 sampleNamesOrigin=rownames(sampleMetadata) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
316 sampleNamesMakeNames=make.names(sampleNamesOrigin) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
317 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
318 if (any(duplicated(sampleNamesMakeNames))) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
319 write("\n\nERROR: Usually, R has trouble to deal with special characters in its column names, so it rename them using make.names().\nIn your case, at least two columns after the renaming obtain the same name, thus XCMS will collapse those columns per name.", stderr()) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
320 for (sampleName in sampleNamesOrigin) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
321 write(paste(sampleName,"\t->\t",make.names(sampleName)),stderr()) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
322 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
323 stop("\n\nERROR: One or more of your files will not be import by xcmsSet. It may due to bad characters in their filenames.") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
324 } |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
325 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
326 if (!all(sampleNamesOrigin == sampleNamesMakeNames)) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
327 cat("\n\nWARNING: Usually, R has trouble to deal with special characters in its column names, so it rename them using make.names()\nIn your case, one or more sample names will be renamed in the sampleMetadata and dataMatrix files:\n") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
328 for (sampleName in sampleNamesOrigin) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
329 cat(paste(sampleName,"\t->\t",make.names(sampleName),"\n")) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
330 } |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
331 } |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
332 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
333 sampleMetadata$sampleMetadata=sampleNamesMakeNames |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
334 sampleMetadata=cbind(sampleMetadata["sampleMetadata"],sampleMetadata["class"]) #Reorder columns |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
335 rownames(sampleMetadata)=NULL |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
336 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
337 #Create a list of files name in the current directory |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
338 list_files=xset@filepaths |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
339 #For each sample file, the following actions are done |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
340 for (file in list_files){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
341 #Check if the file is in the CDF format |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
342 if (!mzR:::netCDFIsFile(file)){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
343 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
344 # If the column isn't exist, with add one filled with NA |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
345 if (is.null(sampleMetadata$polarity)) sampleMetadata$polarity=NA |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
346 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
347 #Create a simple xcmsRaw object for each sample |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
348 xcmsRaw=xcmsRaw(file) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
349 #Extract the polarity (a list of polarities) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
350 polarity=xcmsRaw@polarity |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
351 #Verify if all the scans have the same polarity |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
352 uniq_list=unique(polarity) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
353 if (length(uniq_list)>1){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
354 polarity="mixed" |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
355 } else { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
356 polarity=as.character(uniq_list) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
357 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
358 #Transforms the character to obtain only the sample name |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
359 filename=basename(file) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
360 library(tools) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
361 samplename=file_path_sans_ext(filename) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
362 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
363 #Set the polarity attribute |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
364 sampleMetadata$polarity[sampleMetadata$sampleMetadata==samplename]=polarity |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
365 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
366 #Delete xcmsRaw object because it creates a bug for the fillpeaks step |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
367 rm(xcmsRaw) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
368 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
369 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
370 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
371 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
372 write.table(sampleMetadata, sep="\t", quote=FALSE, row.names=FALSE, file=sampleMetadataOutput) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
373 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
374 return(list("sampleNamesOrigin"=sampleNamesOrigin,"sampleNamesMakeNames"=sampleNamesMakeNames)) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
375 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
376 } |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
377 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
378 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
379 ## |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
380 ## This function check if xcms will found all the files |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
381 ## |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
382 #@author Gildas Le Corguille lecorguille@sb-roscoff.fr ABiMS TEAM |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
383 checkFilesCompatibilityWithXcms <- function(directory) { |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
384 cat("Checking files filenames compatibilities with xmcs...\n") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
385 # WHAT XCMS WILL FIND |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
386 filepattern <- c("[Cc][Dd][Ff]", "[Nn][Cc]", "([Mm][Zz])?[Xx][Mm][Ll]","[Mm][Zz][Dd][Aa][Tt][Aa]", "[Mm][Zz][Mm][Ll]") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
387 filepattern <- paste(paste("\\.", filepattern, "$", sep = ""),collapse = "|") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
388 info <- file.info(directory) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
389 listed <- list.files(directory[info$isdir], pattern = filepattern,recursive = TRUE, full.names = TRUE) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
390 files <- c(directory[!info$isdir], listed) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
391 files_abs <- file.path(getwd(), files) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
392 exists <- file.exists(files_abs) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
393 files[exists] <- files_abs[exists] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
394 files[exists] <- sub("//","/",files[exists]) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
395 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
396 # WHAT IS ON THE FILESYSTEM |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
397 filesystem_filepaths=system(paste("find $PWD/",directory," -not -name '\\.*' -not -path '*conda-env*' -type f -name \"*\"", sep=""), intern=T) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
398 filesystem_filepaths=filesystem_filepaths[grep(filepattern, filesystem_filepaths, perl=T)] |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
399 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
400 # COMPARISON |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
401 if (!is.na(table(filesystem_filepaths %in% files)["FALSE"])) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
402 write("\n\nERROR: List of the files which will not be imported by xcmsSet",stderr()) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
403 write(filesystem_filepaths[!(filesystem_filepaths %in% files)],stderr()) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
404 stop("\n\nERROR: One or more of your files will not be import by xcmsSet. It may due to bad characters in their filenames.") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
405 } |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
406 } |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
407 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
408 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
409 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
410 ## |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
411 ## This function check if XML contains special caracters. It also checks integrity and completness. |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
412 ## |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
413 #@author Misharl Monsoor misharl.monsoor@sb-roscoff.fr ABiMS TEAM |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
414 checkXmlStructure <- function (directory) { |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
415 cat("Checking XML structure...\n") |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
416 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
417 cmd=paste("IFS=$'\n'; for xml in $(find",directory,"-not -name '\\.*' -not -path '*conda-env*' -type f -iname '*.*ml*'); do if [ $(xmllint --nonet --noout \"$xml\" 2> /dev/null; echo $?) -gt 0 ]; then echo $xml;fi; done;") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
418 capture=system(cmd,intern=TRUE) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
419 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
420 if (length(capture)>0){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
421 #message=paste("The following mzXML or mzML file is incorrect, please check these files first:",capture) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
422 write("\n\nERROR: The following mzXML or mzML file(s) are incorrect, please check these files first:", stderr()) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
423 write(capture, stderr()) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
424 stop("ERROR: xcmsSet cannot continue with incorrect mzXML or mzML files") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
425 } |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
426 |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
427 } |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
428 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
429 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
430 ## |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
431 ## This function check if XML contain special characters |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
432 ## |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
433 #@author Misharl Monsoor misharl.monsoor@sb-roscoff.fr ABiMS TEAM |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
434 deleteXmlBadCharacters<- function (directory) { |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
435 cat("Checking Non ASCII characters in the XML...\n") |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
436 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
437 processed=F |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
438 l=system( paste("find",directory, "-not -name '\\.*' -not -path '*conda-env*' -type f -iname '*.*ml*'"),intern=TRUE) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
439 for (i in l){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
440 cmd=paste("LC_ALL=C grep '[^ -~]' \"",i,"\"",sep="") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
441 capture=suppressWarnings(system(cmd,intern=TRUE)) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
442 if (length(capture)>0){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
443 cmd=paste("perl -i -pe 's/[^[:ascii:]]//g;'",i) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
444 print( paste("WARNING: Non ASCII characters have been removed from the ",i,"file") ) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
445 c=system(cmd,intern=TRUE) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
446 capture="" |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
447 processed=T |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
448 } |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
449 } |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
450 if (processed) cat("\n\n") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
451 return(processed) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
452 } |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
453 |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
454 |
9
2c1d7df89cf6
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 08e7f269a5c59687a7768be8db5fcb4e4d736093
lecorguille
parents:
4
diff
changeset
|
455 ## |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
456 ## This function will compute MD5 checksum to check the data integrity |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
457 ## |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
458 #@author Gildas Le Corguille lecorguille@sb-roscoff.fr |
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
459 getMd5sum <- function (directory) { |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
460 cat("Compute md5 checksum...\n") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
461 # WHAT XCMS WILL FIND |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
462 filepattern <- c("[Cc][Dd][Ff]", "[Nn][Cc]", "([Mm][Zz])?[Xx][Mm][Ll]","[Mm][Zz][Dd][Aa][Tt][Aa]", "[Mm][Zz][Mm][Ll]") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
463 filepattern <- paste(paste("\\.", filepattern, "$", sep = ""),collapse = "|") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
464 info <- file.info(directory) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
465 listed <- list.files(directory[info$isdir], pattern = filepattern,recursive = TRUE, full.names = TRUE) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
466 files <- c(directory[!info$isdir], listed) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
467 exists <- file.exists(files) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
468 files <- files[exists] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
469 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
470 library(tools) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
471 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
472 #cat("\n\n") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
473 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
474 return(as.matrix(md5sum(files))) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
475 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
476 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
477 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
478 # This function get the raw file path from the arguments |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
479 getRawfilePathFromArguments <- function(singlefile, zipfile, listArguments) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
480 if (!is.null(listArguments[["zipfile"]])) zipfile = listArguments[["zipfile"]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
481 if (!is.null(listArguments[["zipfilePositive"]])) zipfile = listArguments[["zipfilePositive"]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
482 if (!is.null(listArguments[["zipfileNegative"]])) zipfile = listArguments[["zipfileNegative"]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
483 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
484 if (!is.null(listArguments[["singlefile_galaxyPath"]])) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
485 singlefile_galaxyPaths = listArguments[["singlefile_galaxyPath"]]; |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
486 singlefile_sampleNames = listArguments[["singlefile_sampleName"]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
487 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
488 if (!is.null(listArguments[["singlefile_galaxyPathPositive"]])) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
489 singlefile_galaxyPaths = listArguments[["singlefile_galaxyPathPositive"]]; |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
490 singlefile_sampleNames = listArguments[["singlefile_sampleNamePositive"]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
491 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
492 if (!is.null(listArguments[["singlefile_galaxyPathNegative"]])) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
493 singlefile_galaxyPaths = listArguments[["singlefile_galaxyPathNegative"]]; |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
494 singlefile_sampleNames = listArguments[["singlefile_sampleNameNegative"]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
495 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
496 if (exists("singlefile_galaxyPaths")){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
497 singlefile_galaxyPaths = unlist(strsplit(singlefile_galaxyPaths,",")) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
498 singlefile_sampleNames = unlist(strsplit(singlefile_sampleNames,",")) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
499 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
500 singlefile=NULL |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
501 for (singlefile_galaxyPath_i in seq(1:length(singlefile_galaxyPaths))) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
502 singlefile_galaxyPath=singlefile_galaxyPaths[singlefile_galaxyPath_i] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
503 singlefile_sampleName=singlefile_sampleNames[singlefile_galaxyPath_i] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
504 singlefile[[singlefile_sampleName]] = singlefile_galaxyPath |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
505 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
506 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
507 for (argument in c("zipfile","zipfilePositive","zipfileNegative","singlefile_galaxyPath","singlefile_sampleName","singlefile_galaxyPathPositive","singlefile_sampleNamePositive","singlefile_galaxyPathNegative","singlefile_sampleNameNegative")) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
508 listArguments[[argument]]=NULL |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
509 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
510 return(list(zipfile=zipfile, singlefile=singlefile, listArguments=listArguments)) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
511 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
512 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
513 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
514 # This function retrieve the raw file in the working directory |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
515 # - if zipfile: unzip the file with its directory tree |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
516 # - if singlefiles: set symlink with the good filename |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
517 retrieveRawfileInTheWorkingDirectory <- function(singlefile, zipfile) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
518 if(!is.null(singlefile) && (length("singlefile")>0)) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
519 for (singlefile_sampleName in names(singlefile)) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
520 singlefile_galaxyPath = singlefile[[singlefile_sampleName]] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
521 if(!file.exists(singlefile_galaxyPath)){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
522 error_message=paste("Cannot access the sample:",singlefile_sampleName,"located:",singlefile_galaxyPath,". Please, contact your administrator ... if you have one!") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
523 print(error_message); stop(error_message) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
524 } |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
525 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
526 file.symlink(singlefile_galaxyPath,singlefile_sampleName) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
527 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
528 directory = "." |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
529 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
530 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
531 if(!is.null(zipfile) && (zipfile!="")) { |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
532 if(!file.exists(zipfile)){ |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
533 error_message=paste("Cannot access the Zip file:",zipfile,". Please, contact your administrator ... if you have one!") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
534 print(error_message) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
535 stop(error_message) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
536 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
537 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
538 #list all file in the zip file |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
539 #zip_files=unzip(zipfile,list=T)[,"Name"] |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
540 |
10
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
541 #unzip |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
542 suppressWarnings(unzip(zipfile, unzip="unzip")) |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
543 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
544 #get the directory name |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
545 filesInZip=unzip(zipfile, list=T); |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
546 directories=unique(unlist(lapply(strsplit(filesInZip$Name,"/"), function(x) x[1]))); |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
547 directories=directories[!(directories %in% c("__MACOSX")) & file.info(directories)$isdir] |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
548 directory = "." |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
549 if (length(directories) == 1) directory = directories |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
550 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
551 cat("files_root_directory\t",directory,"\n") |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
552 |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
553 } |
c81275aee959
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit a6f5f18b3d6130f7d7fbb9f2df856838c6217797
lecorguille
parents:
9
diff
changeset
|
554 return (directory) |
4
2db1d1d0f131
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 83b80dcd96b379518c2e4ace992affc889d32ca6
lecorguille
parents:
diff
changeset
|
555 } |