Mercurial > repos > lecorguille > xcms_fillpeaks
comparison lib.r @ 14:8a23c743e6ea draft
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 92dd69e5b063aad05a9b2b75e21c78bfa46c4b94
| author | lecorguille |
|---|---|
| date | Thu, 22 Dec 2016 06:00:11 -0500 |
| parents | f00e39a4b0fb |
| children | 1c78d61fd646 |
comparison
equal
deleted
inserted
replaced
| 13:549105937c71 | 14:8a23c743e6ea |
|---|---|
| 1 # lib.r version="2.0.1" | 1 # lib.r version="2.3" |
| 2 #Authors ABiMS TEAM | 2 #Authors ABiMS TEAM |
| 3 #Lib.r for Galaxy Workflow4Metabo | 3 #Lib.r for Galaxy Workflow4Metabo |
| 4 #version 2.2 | 4 #version 2.3 |
| 5 #Based on lib.r 2.1 | 5 #Based on lib.r 2.1 |
| 6 #Modifications made by Guitton Yann | 6 #Modifications made by Guitton Yann |
| 7 #2.3 Note | |
| 8 #correction for empty PDF when only 1 class | |
| 9 #2.2 Note | |
| 7 #correct bug in Base Peak Chromatogram (BPC) option, not only TIC when scanrange used in xcmsSet | 10 #correct bug in Base Peak Chromatogram (BPC) option, not only TIC when scanrange used in xcmsSet |
| 8 #Note if scanrange is used a warning is prompted in R console but do not stop PDF generation | 11 #Note if scanrange is used a warning is prompted in R console but do not stop PDF generation |
| 9 | 12 |
| 10 | 13 |
| 11 | 14 |
| 112 colvect<-append(colvect,cols[classnames[[l]][j]]) | 115 colvect<-append(colvect,cols[classnames[[l]][j]]) |
| 113 } | 116 } |
| 114 legend("topright",paste(basename(files[c(classnames[[k]],classnames[[l]])])), col = colvect, lty = lty, pch = pch) | 117 legend("topright",paste(basename(files[c(classnames[[k]],classnames[[l]])])), col = colvect, lty = lty, pch = pch) |
| 115 | 118 |
| 116 }#end length ==2 | 119 }#end length ==2 |
| 117 | 120 |
| 121 #case where only one class | |
| 122 if (length(class)==1){ | |
| 123 k=1 | |
| 124 ylim = range(sapply(TIC, function(x) range(x[,2]))) | |
| 125 colvect<-NULL | |
| 126 plot(0, 0, type="n", xlim = xlim/60, ylim = ylim, main = paste("Base Peak Chromatograms \n","BPCs_",class[k], sep=""), xlab = "Retention Time (min)", ylab = "BPC") | |
| 127 | |
| 128 for (j in 1:length(classnames[[k]])) { | |
| 129 tic <- TIC[[classnames[[k]][j]]] | |
| 130 # points(tic[,1]/60, tic[,2], col = cols[i], pch = pch[i], type="l") | |
| 131 points(tic[,1]/60, tic[,2], col = cols[classnames[[k]][j]], pch = pch[classnames[[k]][j]], type="l") | |
| 132 colvect<-append(colvect,cols[classnames[[k]][j]]) | |
| 133 } | |
| 134 | |
| 135 legend("topright",paste(basename(files[c(classnames[[k]])])), col = colvect, lty = lty, pch = pch) | |
| 136 | |
| 137 }#end length ==1 | |
| 138 | |
| 118 dev.off() #pdf(pdfname,w=16,h=10) | 139 dev.off() #pdf(pdfname,w=16,h=10) |
| 119 | 140 |
| 120 invisible(TIC) | 141 invisible(TIC) |
| 121 } | 142 } |
| 122 | 143 |
| 217 colvect<-append(colvect,cols[classnames[[l]][j]]) | 238 colvect<-append(colvect,cols[classnames[[l]][j]]) |
| 218 } | 239 } |
| 219 legend("topright",paste(basename(files[c(classnames[[k]],classnames[[l]])])), col = colvect, lty = lty, pch = pch) | 240 legend("topright",paste(basename(files[c(classnames[[k]],classnames[[l]])])), col = colvect, lty = lty, pch = pch) |
| 220 | 241 |
| 221 }#end length ==2 | 242 }#end length ==2 |
| 243 | |
| 244 #case where only one class | |
| 245 if (length(class)==1){ | |
| 246 k=1 | |
| 247 ylim = range(sapply(TIC, function(x) range(x[,2]))) | |
| 248 | |
| 249 plot(0, 0, type="n", xlim = xlim/60, ylim = ylim, main = paste("Total Ion Chromatograms \n","TICs_",class[k], sep=""), xlab = "Retention Time (min)", ylab = "TIC") | |
| 250 colvect<-NULL | |
| 251 for (j in 1:length(classnames[[k]])) { | |
| 252 tic <- TIC[[classnames[[k]][j]]] | |
| 253 # points(tic[,1]/60, tic[,2], col = cols[i], pch = pch[i], type="l") | |
| 254 points(tic[,1]/60, tic[,2], col = cols[classnames[[k]][j]], pch = pch[classnames[[k]][j]], type="l") | |
| 255 colvect<-append(colvect,cols[classnames[[k]][j]]) | |
| 256 } | |
| 257 | |
| 258 legend("topright",paste(basename(files[c(classnames[[k]])])), col = colvect, lty = lty, pch = pch) | |
| 259 | |
| 260 }#end length ==1 | |
| 261 | |
| 222 dev.off() #pdf(pdfname,w=16,h=10) | 262 dev.off() #pdf(pdfname,w=16,h=10) |
| 223 | 263 |
| 224 invisible(TIC) | 264 invisible(TIC) |
| 225 } | 265 } |
| 226 | 266 |
