changeset 12:e3eda5cff0b6 draft

planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 92dd69e5b063aad05a9b2b75e21c78bfa46c4b94
author lecorguille
date Thu, 22 Dec 2016 05:59:36 -0500
parents dc29a74d307b
children 206e5a968dc5
files lib.r macros.xml
diffstat 2 files changed, 42 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lib.r	Mon Nov 14 16:19:18 2016 -0500
+++ b/lib.r	Thu Dec 22 05:59:36 2016 -0500
@@ -1,9 +1,12 @@
-# lib.r version="2.0.1"
+# lib.r version="2.3"
 #Authors ABiMS TEAM
 #Lib.r for Galaxy Workflow4Metabo
-#version 2.2
+#version 2.3
 #Based on lib.r 2.1
 #Modifications made by Guitton Yann 
+#2.3 Note
+#correction for empty PDF when only 1 class
+#2.2 Note
 #correct bug in Base Peak Chromatogram (BPC) option, not only TIC when scanrange used in xcmsSet
 #Note if scanrange is used a warning is prompted in R console but do not stop PDF generation
 
@@ -114,7 +117,25 @@
     legend("topright",paste(basename(files[c(classnames[[k]],classnames[[l]])])), col = colvect, lty = lty, pch = pch)
 
   }#end length ==2
+  
+  #case where only one class
+  if (length(class)==1){
+    k=1
+		ylim = range(sapply(TIC, function(x) range(x[,2])))
+    colvect<-NULL
+    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")
 
+    for (j in 1:length(classnames[[k]])) {
+      tic <- TIC[[classnames[[k]][j]]]
+      # points(tic[,1]/60, tic[,2], col = cols[i], pch = pch[i], type="l")
+      points(tic[,1]/60, tic[,2], col = cols[classnames[[k]][j]], pch = pch[classnames[[k]][j]], type="l")
+      colvect<-append(colvect,cols[classnames[[k]][j]])
+    }
+      
+    legend("topright",paste(basename(files[c(classnames[[k]])])), col = colvect, lty = lty, pch = pch)
+
+  }#end length ==1
+                        
   dev.off() #pdf(pdfname,w=16,h=10)
 
   invisible(TIC)
@@ -219,6 +240,25 @@
     legend("topright",paste(basename(files[c(classnames[[k]],classnames[[l]])])), col = colvect, lty = lty, pch = pch)
 
   }#end length ==2
+    
+  #case where only one class
+  if (length(class)==1){
+	  k=1
+	  ylim = range(sapply(TIC, function(x) range(x[,2])))
+				
+	  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")
+    colvect<-NULL
+		for (j in 1:length(classnames[[k]])) {
+      tic <- TIC[[classnames[[k]][j]]]
+			# points(tic[,1]/60, tic[,2], col = cols[i], pch = pch[i], type="l")
+			points(tic[,1]/60, tic[,2], col = cols[classnames[[k]][j]], pch = pch[classnames[[k]][j]], type="l")
+      colvect<-append(colvect,cols[classnames[[k]][j]])
+	  }
+		
+		legend("topright",paste(basename(files[c(classnames[[k]])])), col = colvect, lty = lty, pch = pch)
+	  
+	}#end length ==1
+                        
   dev.off() #pdf(pdfname,w=16,h=10)
 
   invisible(TIC)
--- a/macros.xml	Mon Nov 14 16:19:18 2016 -0500
+++ b/macros.xml	Thu Dec 22 05:59:36 2016 -0500
@@ -2,7 +2,6 @@
 <macros>
     <xml name="requirements">
         <requirements>
-            <requirement type="package" version="3.1.2">R</requirement>
             <requirement type="package" version="0.4_1">r-snow</requirement>
             <requirement type="package" version="1.46.0">bioconductor-xcms</requirement>
             <requirement type="package" version="1.1_4">r-batch</requirement>