Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

Commit

Permalink
Merge pull request #32 from workflow4metabolomics/drop_new-file_path
Browse files Browse the repository at this point in the history
Drop new file path
  • Loading branch information
lecorguille authored Apr 5, 2017
2 parents 9649805 + 1b6a134 commit 896ef11
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 50 deletions.
3 changes: 2 additions & 1 deletion galaxy/camera_annotate/abims_CAMERA_annotateDiffreport.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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@
Expand Down Expand Up @@ -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>

Expand Down
6 changes: 1 addition & 5 deletions src/camera_w4m_script/CAMERA.r
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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"]]
Expand Down
88 changes: 44 additions & 44 deletions src/camera_w4m_script/lib.r
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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')

Expand Down Expand Up @@ -97,43 +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), ]
}

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)
}
}
}
}
}
}


Expand All @@ -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), ]
}
}

Expand Down

0 comments on commit 896ef11

Please sign in to comment.