From 666f4262b017272f2c7bf5002c0371efbf5b5142 Mon Sep 17 00:00:00 2001 From: lecorguille Date: Wed, 5 Apr 2017 17:05:42 +0200 Subject: [PATCH 1/2] drop the new_file_path data discover --- .../abims_CAMERA_annotateDiffreport.xml | 3 ++- src/camera_w4m_script/CAMERA.r | 6 +---- src/camera_w4m_script/lib.r | 22 +++++++++---------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/galaxy/camera_annotate/abims_CAMERA_annotateDiffreport.xml b/galaxy/camera_annotate/abims_CAMERA_annotateDiffreport.xml index e1744b3..bdb76e7 100644 --- a/galaxy/camera_annotate/abims_CAMERA_annotateDiffreport.xml +++ b/galaxy/camera_annotate/abims_CAMERA_annotateDiffreport.xml @@ -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 @@ diff --git a/src/camera_w4m_script/CAMERA.r b/src/camera_w4m_script/CAMERA.r index f62d719..2030267 100644 --- a/src/camera_w4m_script/CAMERA.r +++ b/src/camera_w4m_script/CAMERA.r @@ -91,10 +91,6 @@ if (!is.null(listArguments[["variableMetadataOutput"]])){ 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 @@ pdf(file=rplotspdf, width=16, height=12) 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"]] diff --git a/src/camera_w4m_script/lib.r b/src/camera_w4m_script/lib.r index 17f4d1f..ce812da 100644 --- a/src/camera_w4m_script/lib.r +++ b/src/camera_w4m_script/lib.r @@ -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) { +diffreport_png2pdf <- function(filebase) { + dir.create("pdf") - pdfEicOutput = paste(new_file_path,filebase,"-eic_visible_pdf",sep="") - pdfBoxOutput = paste(new_file_path,filebase,"-box_visible_pdf",sep="") + pdfEicOutput = paste0("pdf/",filebase,"-eic_pdf.pdf") + pdfBoxOutput = paste0("pdf/",filebase,"-box_pdf.pdf") - system(paste("gm convert ",filebase,"_eic/*.png ",filebase,"_eic.pdf",sep="")) - system(paste("gm convert ",filebase,"_box/*.png ",filebase,"_box.pdf",sep="")) + system(paste0("gm convert ",filebase,"_eic/*.png ",pdfEicOutput)) + system(paste0("gm convert ",filebase,"_box/*.png ",pdfBoxOutput)) - file.copy(paste(filebase,"_eic.pdf",sep=""), pdfEicOutput) - file.copy(paste(filebase,"_box.pdf",sep=""), pdfBoxOutput) } #@author G. Le Corguille @@ -38,7 +37,7 @@ formatIonIdentifiers <- function(variableMetadata, numDigitsRT=0, numDigitsMZ=0) } #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') @@ -126,10 +125,11 @@ annotatediff <- function(xset=xset, listArguments=listArguments, variableMetadat 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="")) + 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, new_file_path) + diffreport_png2pdf(filebase) } } } From 1b6a134c01ec1b7917a3196618ec9431b9059f1a Mon Sep 17 00:00:00 2001 From: lecorguille Date: Wed, 5 Apr 2017 17:08:42 +0200 Subject: [PATCH 2/2] reindent --- src/camera_w4m_script/lib.r | 72 ++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/camera_w4m_script/lib.r b/src/camera_w4m_script/lib.r index ce812da..508fedb 100644 --- a/src/camera_w4m_script/lib.r +++ b/src/camera_w4m_script/lib.r @@ -96,44 +96,44 @@ annotatediff <- function(xset=xset, listArguments=listArguments, variableMetadat # --- 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), ] - } - - 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) + #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 @@ annotatediff <- function(xset=xset, listArguments=listArguments, variableMetadat 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), ] } }