changeset 33:3b2b642542f6 draft

planemo upload commit 896ef116e72008394779322f65137c632af5f4d2
author lecorguille
date Wed, 05 Apr 2017 11:27:56 -0400
parents 23e33e354bb7
children 34d89b4ad869
files CAMERA.r abims_CAMERA_annotateDiffreport.xml lib.r
diffstat 3 files changed, 48 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/CAMERA.r	Wed Apr 05 07:36:44 2017 -0400
+++ b/CAMERA.r	Wed Apr 05 11:27:56 2017 -0400
@@ -91,10 +91,6 @@
     variableMetadataOutput = listArguments[["variableMetadataOutput"]]; listArguments[["variableMetadataOutput"]]=NULL
 }
 
-if (!is.null(listArguments[["new_file_path"]])){
-    new_file_path = listArguments[["new_file_path"]]; listArguments[["new_file_path"]]=NULL
-}
-
 #Import the different functions
 source_local("lib.r")
 
@@ -128,7 +124,7 @@
 
 
 if (thefunction %in% c("annotatediff")) {
-    results_list=annotatediff(xset=xset,listArguments=listArguments,variableMetadataOutput=variableMetadataOutput,dataMatrixOutput=dataMatrixOutput,new_file_path=new_file_path)
+    results_list=annotatediff(xset=xset,listArguments=listArguments,variableMetadataOutput=variableMetadataOutput,dataMatrixOutput=dataMatrixOutput)
     xa=results_list[["xa"]]
     diffrep=results_list[["diffrep"]]
     variableMetadata=results_list[["variableMetadata"]]
--- a/abims_CAMERA_annotateDiffreport.xml	Wed Apr 05 07:36:44 2017 -0400
+++ b/abims_CAMERA_annotateDiffreport.xml	Wed Apr 05 11:27:56 2017 -0400
@@ -67,7 +67,6 @@
             h $diffreport.options.h
             w $diffreport.options.w
             mzdec $diffreport.options.mzdec
-            new_file_path ${__new_file_path__}/primary_${output_diffreport.id}_
         #end if
 
         @COMMAND_PEAKLIST@
@@ -186,6 +185,8 @@
         </data>
         <data name="output_diffreport" format="text" label="${image.name[:-6]}.annotateDiffreport" hidden="true">
             <filter>diffreport['options']['option'] == 'show'</filter>
+            <discover_datasets pattern="__designation_and_ext__" directory="pdf" visible="true" />
+            <discover_datasets pattern="__designation_and_ext__" directory="tabular" visible="true" />
         </data>
     </outputs>
 
--- a/lib.r	Wed Apr 05 07:36:44 2017 -0400
+++ b/lib.r	Wed Apr 05 11:27:56 2017 -0400
@@ -1,17 +1,16 @@
-# lib.r version="2.2.1"
+# lib.r
 
 #@author G. Le Corguille
 #The function create a pdf from the different png generated by diffreport
-diffreport_png2pdf <- function(filebase, new_file_path) {
-
-    pdfEicOutput = paste(new_file_path,filebase,"-eic_visible_pdf",sep="")
-    pdfBoxOutput = paste(new_file_path,filebase,"-box_visible_pdf",sep="")
+diffreport_png2pdf <- function(filebase) {
+    dir.create("pdf")
 
-    system(paste("gm convert ",filebase,"_eic/*.png ",filebase,"_eic.pdf",sep=""))
-    system(paste("gm convert ",filebase,"_box/*.png ",filebase,"_box.pdf",sep=""))
+    pdfEicOutput = paste0("pdf/",filebase,"-eic_pdf.pdf")
+    pdfBoxOutput = paste0("pdf/",filebase,"-box_pdf.pdf")
 
-    file.copy(paste(filebase,"_eic.pdf",sep=""), pdfEicOutput)
-    file.copy(paste(filebase,"_box.pdf",sep=""), pdfBoxOutput)
+    system(paste0("gm convert ",filebase,"_eic/*.png ",pdfEicOutput))
+    system(paste0("gm convert ",filebase,"_box/*.png ",pdfBoxOutput))
+
 }
 
 #@author G. Le Corguille
@@ -38,7 +37,7 @@
 }
 
 #The function annotateDiffreport without the corr function which bugs
-annotatediff <- function(xset=xset, listArguments=listArguments, variableMetadataOutput="variableMetadata.tsv", dataMatrixOutput="dataMatrix.tsv",new_file_path=NULL) {
+annotatediff <- function(xset=xset, listArguments=listArguments, variableMetadataOutput="variableMetadata.tsv", dataMatrixOutput="dataMatrix.tsv") {
     # Resolve the bug with x11, with the function png
     options(bitmapType='cairo')
 
@@ -97,43 +96,44 @@
     # --- Multi condition : diffreport ---
     diffrepOri=NULL
     if (!is.null(listArguments[["runDiffreport"]]) & nlevels(sampclass(xset))>=2) {
-    #Check if the fillpeaks step has been done previously, if it hasn't, there is an error message and the execution is stopped.
-    res=try(is.null(xset@filled))
-    classes=levels(sampclass(xset))
-    x=1:(length(classes)-1)
-    for (i in seq(along=x) ) {
-        y=1:(length(classes))
-        for (n in seq(along=y)){
-            if(i+n <= length(classes)){
-                filebase=paste(classes[i],class2=classes[i+n],sep="-vs-")
-
-                diffrep=diffreport(object=xset,class1=classes[i],class2=classes[i+n],filebase=filebase,eicmax=listArguments[["eicmax"]],eicwidth=listArguments[["eicwidth"]],sortpval=TRUE,value=listArguments[["value"]],h=listArguments[["h"]],w=listArguments[["w"]],mzdec=listArguments[["mzdec"]])
-
-                diffrepOri = diffrep
-
-                # renamming of the column rtmed to rt to fit with camera peaklist function output
-                colnames(diffrep)[colnames(diffrep)=="rtmed"] <- "rt"
-                colnames(diffrep)[colnames(diffrep)=="mzmed"] <- "mz"
-
-                # combines results and reorder columns
-                diffrep = merge(peakList, diffrep[,c("name","fold","tstat","pvalue")], by.x="name", by.y="name", sort=F)
-                diffrep = cbind(diffrep[,!(colnames(diffrep) %in% c(sampnames(xa@xcmsSet)))],diffrep[,(colnames(diffrep) %in% c(sampnames(xa@xcmsSet)))])
-
-                diffrep = RTSecondToMinute(diffrep, listArguments[["convertRTMinute"]])
-                diffrep = formatIonIdentifiers(diffrep, numDigitsRT=listArguments[["numDigitsRT"]], numDigitsMZ=listArguments[["numDigitsMZ"]])
-
-                if(listArguments[["sortpval"]]){
-                    diffrep=diffrep[order(diffrep$pvalue), ]
-                }
-
-                write.table(diffrep, sep="\t", quote=FALSE, row.names=FALSE, file=paste(new_file_path,filebase,"-tabular_visible_tabular",sep=""))
-
-                if (listArguments[["eicmax"]] != 0) {
-                    diffreport_png2pdf(filebase, new_file_path)
+        #Check if the fillpeaks step has been done previously, if it hasn't, there is an error message and the execution is stopped.
+        res=try(is.null(xset@filled))
+        classes=levels(sampclass(xset))
+        x=1:(length(classes)-1)
+        for (i in seq(along=x) ) {
+            y=1:(length(classes))
+            for (n in seq(along=y)){
+                if(i+n <= length(classes)){
+                    filebase=paste(classes[i],class2=classes[i+n],sep="-vs-")
+                    
+                    diffrep=diffreport(object=xset,class1=classes[i],class2=classes[i+n],filebase=filebase,eicmax=listArguments[["eicmax"]],eicwidth=listArguments[["eicwidth"]],sortpval=TRUE,value=listArguments[["value"]],h=listArguments[["h"]],w=listArguments[["w"]],mzdec=listArguments[["mzdec"]])
+                    
+                    diffrepOri = diffrep
+                    
+                    # renamming of the column rtmed to rt to fit with camera peaklist function output
+                    colnames(diffrep)[colnames(diffrep)=="rtmed"] <- "rt"
+                    colnames(diffrep)[colnames(diffrep)=="mzmed"] <- "mz"
+                    
+                    # combines results and reorder columns
+                    diffrep = merge(peakList, diffrep[,c("name","fold","tstat","pvalue")], by.x="name", by.y="name", sort=F)
+                    diffrep = cbind(diffrep[,!(colnames(diffrep) %in% c(sampnames(xa@xcmsSet)))],diffrep[,(colnames(diffrep) %in% c(sampnames(xa@xcmsSet)))])
+                    
+                    diffrep = RTSecondToMinute(diffrep, listArguments[["convertRTMinute"]])
+                    diffrep = formatIonIdentifiers(diffrep, numDigitsRT=listArguments[["numDigitsRT"]], numDigitsMZ=listArguments[["numDigitsMZ"]])
+                    
+                    if(listArguments[["sortpval"]]){
+                        diffrep=diffrep[order(diffrep$pvalue), ]
+                    }
+                    
+                    dir.create("tabular")
+                    write.table(diffrep, sep="\t", quote=FALSE, row.names=FALSE, file=paste("tabular/",filebase,"_tsv.tabular",sep=""))
+                    
+                    if (listArguments[["eicmax"]] != 0) {
+                        diffreport_png2pdf(filebase)
+                    }
                 }
             }
         }
-        }
     }
 
 
@@ -145,7 +145,7 @@
     if (!is.null(listArguments[["runDiffreport"]]) & nlevels(sampclass(xset))==2) {
         variableMetadata = merge(variableMetadata, diffrep[,c("name","fold","tstat","pvalue")],by.x="name", by.y="name", sort=F)
         if(exists("listArguments[[\"sortpval\"]]")){
-          variableMetadata=variableMetadata[order(variableMetadata$pvalue), ]
+            variableMetadata=variableMetadata[order(variableMetadata$pvalue), ]
         }
     }