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