Mercurial > repos > yguitton > metams_rungc
changeset 3:c75532b75ba1 draft
Uploaded version 2.1.1
author | yguitton |
---|---|
date | Thu, 08 Jun 2017 11:53:35 -0400 |
parents | 8e1b99a7d733 |
children | c10824185547 |
files | lib_metams.r metams.r metams_runGC.xml |
diffstat | 3 files changed, 388 insertions(+), 251 deletions(-) [+] |
line wrap: on
line diff
--- a/lib_metams.r Wed May 24 07:39:18 2017 -0400 +++ b/lib_metams.r Thu Jun 08 11:53:35 2017 -0400 @@ -1,6 +1,7 @@ -# lib_metams.r version 0.99.6 +# lib_metams.r version 2.0.0 # R function for metaMS runGC under W4M # author Yann GUITTON CNRS IRISA/LINA Idealg project 2014-2015 +# author Yann GUITTON Oniris Laberca 2015-2017 ##ADDITIONS FROM Y. Guitton @@ -245,249 +246,335 @@ ##Annotation table each value is a pcgrp associated to the unknown ##NOTE pcgrp index are different between xcmsSet and resGC due to filtering steps in metaMS ##R. Wehrens give me some clues on that and we found a correction - - mat<-matrix(ncol=length(resGC$xset), nrow=dim(resGC$PeakTable)[1]) - - for (j in 1: length(resGC$xset)){ - test<-resGC$annotation[[j]] - print(paste("j=",j)) - for (i in 1:dim(test)[1]){ - if (as.numeric(row.names(test)[i])>dim(mat)[1]){ - next - } else { - mat[as.numeric(row.names(test)[i]),j]<-test[i,1] - } + #if unkn="none" + + if(unkn=="none") { + pdf("Unknown_Empty.pdf") + plot.new() + text(x=0.5,y=1,pos=1, labels="No EIC ploting required") + dev.off() + }else { + + mat<-matrix(ncol=length(resGC$xset), nrow=dim(resGC$PeakTable)[1]) + + for (j in 1: length(resGC$xset)){ + test<-resGC$annotation[[j]] + print(paste("j=",j)) + for (i in 1:dim(test)[1]){ + if (as.numeric(row.names(test)[i])>dim(mat)[1]){ + next + } else { + mat[as.numeric(row.names(test)[i]),j]<-test[i,1] + } + } + } + colnames(mat)<-colnames(resGC$PeakTable[,c((which(colnames(resGC$PeakTable)=="rt"|colnames(resGC$PeakTable)=="RI")[length(which(colnames(resGC$PeakTable)=="rt"|colnames(resGC$PeakTable)=="RI"))]+1):dim(resGC$PeakTable)[2])]) + + #debug + + # print(dim(mat)) + # print(mat[1:3,]) + # write.table(mat, file="myannotationtable.tsv", sep="\t", row.names=FALSE) + #correction of annotation matrix due to pcgrp removal by quality check in runGCresult + #matrix of correspondance between an@pspectra and filtered pspectra from runGC + + allPCGRPs <- + lapply(1:length(resGC$xset), + function(i) { + an <- resGC$xset[[i]] + huhn <- an@pspectra[which(sapply(an@pspectra, length) >= + metaSetting(resGC$settings, + "DBconstruction.minfeat"))] + matCORR<-cbind(1:length(huhn), match(huhn, an@pspectra)) + }) + + if (unkn[1]==""){ + #plot EIC and spectra for all unknown for comparative purpose + + + par (mar=c(5, 4, 4, 2) + 0.1) + for (l in 1:dim(resGC$PeakTable)[1]){ #l=2 + #recordPlot + perpage=3 #if change change layout also! + num.plots <- ceiling(dim(mat)[2]/perpage) #three pcgroup per page + my.plots <- vector(num.plots, mode='list') + dev.new(width=21/2.54, height=29.7/2.54, file=paste("Unknown_",l,".pdf", sep="")) #A4 pdf + # par(mfrow=c(perpage,2)) + layout(matrix(c(1,1,2,3,4,4,5,6,7,7,8,9), 6, 2, byrow = TRUE), widths=rep(c(1,1),perpage), heights=rep(c(1,5),perpage)) + # layout.show(6) + oma.saved <- par("oma") + par(oma = rep.int(0, 4)) + par(oma = oma.saved) + o.par <- par(mar = rep.int(0, 4)) + on.exit(par(o.par)) + stop=0 #initialize + for (i in 1:num.plots) { + start=stop+1 + stop=start+perpage-1 # + for (c in start:stop){ + if (c <=dim(mat)[2]){ + + #get sample name + sampname<-basename(resGC$xset[[c]]@xcmsSet@filepaths) + + #remove .cdf, .mzXML filepattern + filepattern <- c("[Cc][Dd][Ff]", "[Nn][Cc]", "([Mm][Zz])?[Xx][Mm][Ll]", + "[Mm][Zz][Dd][Aa][Tt][Aa]", "[Mm][Zz][Mm][Ll]") + filepattern <- paste(paste("\\.", filepattern, "$", sep = ""), + collapse = "|") + sampname<-gsub(filepattern, "",sampname) + + title1<-paste("unknown", l,"from",sampname, sep=" ") + an<-resGC$xset[[c]] + + par (mar=c(0, 0, 0, 0) + 0.1) + plot.new() + box() + text(0.5, 0.5, title1, cex=2) + if (!is.na(mat[l,c])){ + pcgrp=allPCGRPs[[c]][which(allPCGRPs[[c]][,1]==mat[l,c]),2] + if (pcgrp!=mat[l,c]) print ("pcgrp changed") + par (mar=c(3, 2.5, 3, 1.5) + 0.1) + plotEICs(an, pspec=pcgrp, maxlabel=2) + plotPsSpectrum(an, pspec=pcgrp, maxlabel=2) + } else { + plot.new() + box() + text(0.5, 0.5, "NOT FOUND", cex=2) + plot.new() + box() + text(0.5, 0.5, "NOT FOUND", cex=2) + } + } + } + # my.plots[[i]] <- recordPlot() + } + graphics.off() + + # pdf(file=paste("Unknown_",l,".pdf", sep=""), onefile=TRUE) + # for (my.plot in my.plots) { + # replayPlot(my.plot) + # } + # my.plots + # graphics.off() + + }#end for l + }#end if unkn="" + else{ + par (mar=c(5, 4, 4, 2) + 0.1) + l=unkn + if (length(l)==1){ + #recordPlot + perpage=3 #if change change layout also! + num.plots <- ceiling(dim(mat)[2]/perpage) #three pcgroup per page + my.plots <- vector(num.plots, mode='list') + + dev.new(width=21/2.54, height=29.7/2.54, file=paste("Unknown_",l,".pdf", sep="")) #A4 pdf + # par(mfrow=c(perpage,2)) + layout(matrix(c(1,1,2,3,4,4,5,6,7,7,8,9), 6, 2, byrow = TRUE), widths=rep(c(1,1),perpage), heights=rep(c(1,5),perpage)) + # layout.show(6) + oma.saved <- par("oma") + par(oma = rep.int(0, 4)) + par(oma = oma.saved) + o.par <- par(mar = rep.int(0, 4)) + on.exit(par(o.par)) + stop=0 #initialize + for (i in 1:num.plots) { + start=stop+1 + stop=start+perpage-1 # + for (c in start:stop){ + if (c <=dim(mat)[2]){ + + #get sample name + sampname<-basename(resGC$xset[[c]]@xcmsSet@filepaths) + + #remove .cdf, .mzXML filepattern + filepattern <- c("[Cc][Dd][Ff]", "[Nn][Cc]", "([Mm][Zz])?[Xx][Mm][Ll]", "[Mm][Zz][Dd][Aa][Tt][Aa]", "[Mm][Zz][Mm][Ll]") + filepattern <- paste(paste("\\.", filepattern, "$", sep = ""), collapse = "|") + sampname<-gsub(filepattern, "",sampname) + + title1<-paste("unknown", l,"from",sampname, sep=" ") + an<-resGC$xset[[c]] + + par (mar=c(0, 0, 0, 0) + 0.1) + plot.new() + box() + text(0.5, 0.5, title1, cex=2) + if (!is.na(mat[l,c])){ + pcgrp=allPCGRPs[[c]][which(allPCGRPs[[c]][,1]==mat[l,c]),2] + if (pcgrp!=mat[l,c]) print ("pcgrp changed") + par (mar=c(3, 2.5, 3, 1.5) + 0.1) + plotEICs(an, pspec=pcgrp, maxlabel=2) + plotPsSpectrum(an, pspec=pcgrp, maxlabel=2) + } else { + plot.new() + box() + text(0.5, 0.5, "NOT FOUND", cex=2) + plot.new() + box() + text(0.5, 0.5, "NOT FOUND", cex=2) + } + } + } + # my.plots[[i]] <- recordPlot() + } + graphics.off() + + # pdf(file=paste("Unknown_",l,".pdf", sep=""), onefile=TRUE) + # for (my.plot in my.plots) { + # replayPlot(my.plot) + # } + # my.plots + # graphics.off() + } else { + par (mar=c(5, 4, 4, 2) + 0.1) + for (l in 1:length(unkn)){ #l=2 + #recordPlot + perpage=3 #if change change layout also! + num.plots <- ceiling(dim(mat)[2]/perpage) #three pcgroup per page + my.plots <- vector(num.plots, mode='list') + dev.new(width=21/2.54, height=29.7/2.54, file=paste("Unknown_",unkn[l],".pdf", sep="")) #A4 pdf + # par(mfrow=c(perpage,2)) + layout(matrix(c(1,1,2,3,4,4,5,6,7,7,8,9), 6, 2, byrow = TRUE), widths=rep(c(1,1),perpage), heights=rep(c(1,5),perpage)) + # layout.show(6) + oma.saved <- par("oma") + par(oma = rep.int(0, 4)) + par(oma = oma.saved) + o.par <- par(mar = rep.int(0, 4)) + on.exit(par(o.par)) + stop=0 #initialize + for (i in 1:num.plots) { + start=stop+1 + stop=start+perpage-1 # + for (c in start:stop){ + if (c <=dim(mat)[2]){ + + #get sample name + sampname<-basename(resGC$xset[[c]]@xcmsSet@filepaths) + + #remove .cdf, .mzXML filepattern + filepattern <- c("[Cc][Dd][Ff]", "[Nn][Cc]", "([Mm][Zz])?[Xx][Mm][Ll]", "[Mm][Zz][Dd][Aa][Tt][Aa]", "[Mm][Zz][Mm][Ll]") + filepattern <- paste(paste("\\.", filepattern, "$", sep = ""), collapse = "|") + sampname<-gsub(filepattern, "",sampname) + + title1<-paste("unknown",unkn[l],"from",sampname, sep=" ") + an<-resGC$xset[[c]] + + par (mar=c(0, 0, 0, 0) + 0.1) + plot.new() + box() + text(0.5, 0.5, title1, cex=2) + if (!is.na(mat[unkn[l],c])){ + pcgrp=allPCGRPs[[c]][which(allPCGRPs[[c]][,1]==mat[unkn[l],c]),2] + if (pcgrp!=mat[unkn[l],c]) print ("pcgrp changed") + par (mar=c(3, 2.5, 3, 1.5) + 0.1) + plotEICs(an, pspec=pcgrp, maxlabel=2) + plotPsSpectrum(an, pspec=pcgrp, maxlabel=2) + } else { + plot.new() + box() + text(0.5, 0.5, "NOT FOUND", cex=2) + plot.new() + box() + text(0.5, 0.5, "NOT FOUND", cex=2) + } + } + } + # my.plots[[i]] <- recordPlot() + } + graphics.off() + + # pdf(file=paste("Unknown_",unkn[l],".pdf", sep=""), onefile=TRUE) + # for (my.plot in my.plots) { + # replayPlot(my.plot) + # } + # my.plots + # graphics.off() + + }#end for unkn[l] + + } + + } + } +} #end function + +# This function get the raw file path from the arguments +getRawfilePathFromArguments <- function(singlefile, zipfile, listArguments) { + if (!is.null(listArguments[["zipfile"]])) zipfile = listArguments[["zipfile"]] + if (!is.null(listArguments[["zipfilePositive"]])) zipfile = listArguments[["zipfilePositive"]] + if (!is.null(listArguments[["zipfileNegative"]])) zipfile = listArguments[["zipfileNegative"]] + + if (!is.null(listArguments[["singlefile_galaxyPath"]])) { + singlefile_galaxyPaths = listArguments[["singlefile_galaxyPath"]]; + singlefile_sampleNames = listArguments[["singlefile_sampleName"]] + } + if (!is.null(listArguments[["singlefile_galaxyPathPositive"]])) { + singlefile_galaxyPaths = listArguments[["singlefile_galaxyPathPositive"]]; + singlefile_sampleNames = listArguments[["singlefile_sampleNamePositive"]] + } + if (!is.null(listArguments[["singlefile_galaxyPathNegative"]])) { + singlefile_galaxyPaths = listArguments[["singlefile_galaxyPathNegative"]]; + singlefile_sampleNames = listArguments[["singlefile_sampleNameNegative"]] + } + if (exists("singlefile_galaxyPaths")){ + singlefile_galaxyPaths = unlist(strsplit(singlefile_galaxyPaths,",")) + singlefile_sampleNames = unlist(strsplit(singlefile_sampleNames,",")) + + singlefile=NULL + for (singlefile_galaxyPath_i in seq(1:length(singlefile_galaxyPaths))) { + singlefile_galaxyPath=singlefile_galaxyPaths[singlefile_galaxyPath_i] + singlefile_sampleName=singlefile_sampleNames[singlefile_galaxyPath_i] + singlefile[[singlefile_sampleName]] = singlefile_galaxyPath } } - colnames(mat)<-colnames(resGC$PeakTable[,c((which(colnames(resGC$PeakTable)=="rt"|colnames(resGC$PeakTable)=="RI")[length(which(colnames(resGC$PeakTable)=="rt"|colnames(resGC$PeakTable)=="RI"))]+1):dim(resGC$PeakTable)[2])]) - - #debug - - # print(dim(mat)) - # print(mat[1:3,]) - # write.table(mat, file="myannotationtable.tsv", sep="\t", row.names=FALSE) - #correction of annotation matrix due to pcgrp removal by quality check in runGCresult - #matrix of correspondance between an@pspectra and filtered pspectra from runGC - - allPCGRPs <- - lapply(1:length(resGC$xset), - function(i) { - an <- resGC$xset[[i]] - huhn <- an@pspectra[which(sapply(an@pspectra, length) >= - metaSetting(resGC$settings, - "DBconstruction.minfeat"))] - matCORR<-cbind(1:length(huhn), match(huhn, an@pspectra)) - }) - - if (unkn[1]==""){ - #plot EIC and spectra for all unknown for comparative purpose - - - par (mar=c(5, 4, 4, 2) + 0.1) - for (l in 1:dim(resGC$PeakTable)[1]){ #l=2 - #recordPlot - perpage=3 #if change change layout also! - num.plots <- ceiling(dim(mat)[2]/perpage) #three pcgroup per page - my.plots <- vector(num.plots, mode='list') - dev.new(width=21/2.54, height=29.7/2.54, file=paste("Unknown_",l,".pdf", sep="")) #A4 pdf - # par(mfrow=c(perpage,2)) - layout(matrix(c(1,1,2,3,4,4,5,6,7,7,8,9), 6, 2, byrow = TRUE), widths=rep(c(1,1),perpage), heights=rep(c(1,5),perpage)) - # layout.show(6) - oma.saved <- par("oma") - par(oma = rep.int(0, 4)) - par(oma = oma.saved) - o.par <- par(mar = rep.int(0, 4)) - on.exit(par(o.par)) - stop=0 #initialize - for (i in 1:num.plots) { - start=stop+1 - stop=start+perpage-1 # - for (c in start:stop){ - if (c <=dim(mat)[2]){ - - #get sample name - sampname<-basename(resGC$xset[[c]]@xcmsSet@filepaths) - - #remove .cdf, .mzXML filepattern - filepattern <- c("[Cc][Dd][Ff]", "[Nn][Cc]", "([Mm][Zz])?[Xx][Mm][Ll]", - "[Mm][Zz][Dd][Aa][Tt][Aa]", "[Mm][Zz][Mm][Ll]") - filepattern <- paste(paste("\\.", filepattern, "$", sep = ""), - collapse = "|") - sampname<-gsub(filepattern, "",sampname) - - title1<-paste("unknown", l,"from",sampname, sep=" ") - an<-resGC$xset[[c]] - - par (mar=c(0, 0, 0, 0) + 0.1) - plot.new() - box() - text(0.5, 0.5, title1, cex=2) - if (!is.na(mat[l,c])){ - pcgrp=allPCGRPs[[c]][which(allPCGRPs[[c]][,1]==mat[l,c]),2] - if (pcgrp!=mat[l,c]) print ("pcgrp changed") - par (mar=c(3, 2.5, 3, 1.5) + 0.1) - plotEICs(an, pspec=pcgrp, maxlabel=2) - plotPsSpectrum(an, pspec=pcgrp, maxlabel=2) - } else { - plot.new() - box() - text(0.5, 0.5, "NOT FOUND", cex=2) - plot.new() - box() - text(0.5, 0.5, "NOT FOUND", cex=2) - } - } - } - # my.plots[[i]] <- recordPlot() - } - graphics.off() - - # pdf(file=paste("Unknown_",l,".pdf", sep=""), onefile=TRUE) - # for (my.plot in my.plots) { - # replayPlot(my.plot) - # } - # my.plots - # graphics.off() - - }#end for l - }#end if unkn="" - else{ - par (mar=c(5, 4, 4, 2) + 0.1) - l=unkn - if (length(l)==1){ - #recordPlot - perpage=3 #if change change layout also! - num.plots <- ceiling(dim(mat)[2]/perpage) #three pcgroup per page - my.plots <- vector(num.plots, mode='list') - - dev.new(width=21/2.54, height=29.7/2.54, file=paste("Unknown_",l,".pdf", sep="")) #A4 pdf - # par(mfrow=c(perpage,2)) - layout(matrix(c(1,1,2,3,4,4,5,6,7,7,8,9), 6, 2, byrow = TRUE), widths=rep(c(1,1),perpage), heights=rep(c(1,5),perpage)) - # layout.show(6) - oma.saved <- par("oma") - par(oma = rep.int(0, 4)) - par(oma = oma.saved) - o.par <- par(mar = rep.int(0, 4)) - on.exit(par(o.par)) - stop=0 #initialize - for (i in 1:num.plots) { - start=stop+1 - stop=start+perpage-1 # - for (c in start:stop){ - if (c <=dim(mat)[2]){ - - #get sample name - sampname<-basename(resGC$xset[[c]]@xcmsSet@filepaths) - - #remove .cdf, .mzXML filepattern - filepattern <- c("[Cc][Dd][Ff]", "[Nn][Cc]", "([Mm][Zz])?[Xx][Mm][Ll]", "[Mm][Zz][Dd][Aa][Tt][Aa]", "[Mm][Zz][Mm][Ll]") - filepattern <- paste(paste("\\.", filepattern, "$", sep = ""), collapse = "|") - sampname<-gsub(filepattern, "",sampname) - - title1<-paste("unknown", l,"from",sampname, sep=" ") - an<-resGC$xset[[c]] - - par (mar=c(0, 0, 0, 0) + 0.1) - plot.new() - box() - text(0.5, 0.5, title1, cex=2) - if (!is.na(mat[l,c])){ - pcgrp=allPCGRPs[[c]][which(allPCGRPs[[c]][,1]==mat[l,c]),2] - if (pcgrp!=mat[l,c]) print ("pcgrp changed") - par (mar=c(3, 2.5, 3, 1.5) + 0.1) - plotEICs(an, pspec=pcgrp, maxlabel=2) - plotPsSpectrum(an, pspec=pcgrp, maxlabel=2) - } else { - plot.new() - box() - text(0.5, 0.5, "NOT FOUND", cex=2) - plot.new() - box() - text(0.5, 0.5, "NOT FOUND", cex=2) - } - } - } - # my.plots[[i]] <- recordPlot() - } - graphics.off() - - # pdf(file=paste("Unknown_",l,".pdf", sep=""), onefile=TRUE) - # for (my.plot in my.plots) { - # replayPlot(my.plot) - # } - # my.plots - # graphics.off() - } else { - par (mar=c(5, 4, 4, 2) + 0.1) - for (l in 1:length(unkn)){ #l=2 - #recordPlot - perpage=3 #if change change layout also! - num.plots <- ceiling(dim(mat)[2]/perpage) #three pcgroup per page - my.plots <- vector(num.plots, mode='list') - dev.new(width=21/2.54, height=29.7/2.54, file=paste("Unknown_",unkn[l],".pdf", sep="")) #A4 pdf - # par(mfrow=c(perpage,2)) - layout(matrix(c(1,1,2,3,4,4,5,6,7,7,8,9), 6, 2, byrow = TRUE), widths=rep(c(1,1),perpage), heights=rep(c(1,5),perpage)) - # layout.show(6) - oma.saved <- par("oma") - par(oma = rep.int(0, 4)) - par(oma = oma.saved) - o.par <- par(mar = rep.int(0, 4)) - on.exit(par(o.par)) - stop=0 #initialize - for (i in 1:num.plots) { - start=stop+1 - stop=start+perpage-1 # - for (c in start:stop){ - if (c <=dim(mat)[2]){ - - #get sample name - sampname<-basename(resGC$xset[[c]]@xcmsSet@filepaths) - - #remove .cdf, .mzXML filepattern - filepattern <- c("[Cc][Dd][Ff]", "[Nn][Cc]", "([Mm][Zz])?[Xx][Mm][Ll]", "[Mm][Zz][Dd][Aa][Tt][Aa]", "[Mm][Zz][Mm][Ll]") - filepattern <- paste(paste("\\.", filepattern, "$", sep = ""), collapse = "|") - sampname<-gsub(filepattern, "",sampname) - - title1<-paste("unknown",unkn[l],"from",sampname, sep=" ") - an<-resGC$xset[[c]] - - par (mar=c(0, 0, 0, 0) + 0.1) - plot.new() - box() - text(0.5, 0.5, title1, cex=2) - if (!is.na(mat[unkn[l],c])){ - pcgrp=allPCGRPs[[c]][which(allPCGRPs[[c]][,1]==mat[unkn[l],c]),2] - if (pcgrp!=mat[unkn[l],c]) print ("pcgrp changed") - par (mar=c(3, 2.5, 3, 1.5) + 0.1) - plotEICs(an, pspec=pcgrp, maxlabel=2) - plotPsSpectrum(an, pspec=pcgrp, maxlabel=2) - } else { - plot.new() - box() - text(0.5, 0.5, "NOT FOUND", cex=2) - plot.new() - box() - text(0.5, 0.5, "NOT FOUND", cex=2) - } - } - } - # my.plots[[i]] <- recordPlot() - } - graphics.off() - - # pdf(file=paste("Unknown_",unkn[l],".pdf", sep=""), onefile=TRUE) - # for (my.plot in my.plots) { - # replayPlot(my.plot) - # } - # my.plots - # graphics.off() - - }#end for unkn[l] - - } - + for (argument in c("zipfile","zipfilePositive","zipfileNegative","singlefile_galaxyPath","singlefile_sampleName","singlefile_galaxyPathPositive","singlefile_sampleNamePositive","singlefile_galaxyPathNegative","singlefile_sampleNameNegative")) { + listArguments[[argument]]=NULL } -} #end function + return(list(zipfile=zipfile, singlefile=singlefile, listArguments=listArguments)) +} +# This function retrieve the raw file in the working directory +# - if zipfile: unzip the file with its directory tree +# - if singlefiles: set symlink with the good filename +retrieveRawfileInTheWorkingDirectory <- function(singlefile, zipfile) { + if(!is.null(singlefile) && (length("singlefile")>0)) { + for (singlefile_sampleName in names(singlefile)) { + singlefile_galaxyPath = singlefile[[singlefile_sampleName]] + if(!file.exists(singlefile_galaxyPath)){ + error_message=paste("Cannot access the sample:",singlefile_sampleName,"located:",singlefile_galaxyPath,". Please, contact your administrator ... if you have one!") + print(error_message); stop(error_message) + } + file.symlink(singlefile_galaxyPath,singlefile_sampleName) + } + directory = "." + + } + if(!is.null(zipfile) && (zipfile!="")) { + if(!file.exists(zipfile)){ + error_message=paste("Cannot access the Zip file:",zipfile,". Please, contact your administrator ... if you have one!") + print(error_message) + stop(error_message) + } + + #list all file in the zip file + #zip_files=unzip(zipfile,list=T)[,"Name"] + + #unzip + suppressWarnings(unzip(zipfile, unzip="unzip")) + + #get the directory name + filesInZip=unzip(zipfile, list=T); + directories=unique(unlist(lapply(strsplit(filesInZip$Name,"/"), function(x) x[1]))); + directories=directories[!(directories %in% c("__MACOSX")) & file.info(directories)$isdir] + directory = "." + if (length(directories) == 1) directory = directories + + cat("files_root_directory\t",directory,"\n") + + } + return (directory) +} +
--- a/metams.r Wed May 24 07:39:18 2017 -0400 +++ b/metams.r Thu Jun 08 11:53:35 2017 -0400 @@ -1,7 +1,7 @@ #!/usr/local/public/bin/Rscript --vanilla --slave --no-site-file -# metams.r version="2.0" +# metams.r version="2.1.1" #created by Yann GUITTON -#use RI options +#use RI options + add try on plotUnknown add session Info #Redirect all stdout to the log file log_file=file("metams.log", open = "wt") @@ -16,13 +16,24 @@ base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)) source(paste(base_dir, fname, sep="/")) } -print("step1") +# print("step1") listArguments = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects -print("new version 2.0") +# print("new version 2.0") +## constants +##---------- + +modNamC <- "metaMS:runGC" ## module name +## log file +##--------- +cat("\nStart of the '", modNamC, "' Galaxy module call: ", +format(Sys.time(), "%a %d %b %Y %X"), "\n", sep="") + + +cat("\n1) Parameters:\n") print(listArguments) @@ -343,8 +354,13 @@ #to do check if no peaks found #Quality controls plots but only working in R (don't know why) -a<-plotUnknowns(resGC=resGC, unkn=unknarg) #use unknparam value - +a<-try(plotUnknowns(resGC=resGC, unkn=unknarg)); #use unknparam value +if(class(a) == "try-error") { + pdf("Unknown_Error.pdf") + plot.new() + text(x=0.5,y=1,pos=1, labels="Error generating EICs\n please use none instead of a vector in plotUnknown") + dev.off() +} # create a mergpdf #test @@ -370,3 +386,27 @@ #saving R data in .Rdata file to save the variables used in the present tool save.image(paste("runGC","RData",sep=".")) +## Closing +##-------- + +cat("\nEnd of '", modNamC, "' Galaxy module call: ", + as.character(Sys.time()), "\n", sep = "") + +cat("\n\n\n============================================================================") +cat("\nAdditional information about the call:\n") +# cat("\n1) Parameters:\n") +# print(cbind(value = argVc)) + +cat("\n1) Session Info:\n") +sessioninfo <- sessionInfo() +cat(sessioninfo$R.version$version.string,"\n") +cat("Main packages:\n") +for (pkg in names(sessioninfo$otherPkgs)) { cat(paste(pkg,packageVersion(pkg)),"\t") }; cat("\n") +cat("Other loaded packages:\n") +for (pkg in names(sessioninfo$loadedOnly)) { cat(paste(pkg,packageVersion(pkg)),"\t") }; cat("\n") + +cat("============================================================================\n") + +sink() + +rm(list = ls()) \ No newline at end of file
--- a/metams_runGC.xml Wed May 24 07:39:18 2017 -0400 +++ b/metams_runGC.xml Thu Jun 08 11:53:35 2017 -0400 @@ -1,4 +1,4 @@ - <tool id="metams_runGC" name="metaMS.runGC" version="2.1"> + <tool id="metams_runGC" name="metaMS.runGC" version="2.1.1"> <description>GC-MS data preprocessing using metaMS package</description> @@ -57,7 +57,11 @@ db "NULL" #end if nSlaves \${GALAXY_SLOTS:-1} - unkn "c($unkn)" + #if $unkn == "none": + unkn "none" + #elif $unkn != "none": + unkn "c($unkn)" + #end if </command> @@ -128,7 +132,7 @@ <when value="hide" /> </conditional> - <param name="rtdiff" type="float" value="0.05" label="RT_Diff" help="The allowed RT shift between same molecule in different sample" /> + <param name="rtdiff" type="float" value="0.05" label="RT_Diff" help="The allowed RT shift in minutes between same molecule in different sample" /> <param name="minfeat" type="integer" value="5" label="Min_Features" help="The minimum number of ion in a mass spectra to consider it a molecule" /> <param name="simthreshold" type="float" value="0.70" label="similarity_threshold" help="The minimum similarity allowed between peaks mass spectra to be considered as equal" /> <param name="minclassfraction" type="float" value="0.5" label="min.class.fract" help="The fraction of samples in which a pseudospectrum is present before it is regarded as an unknown" /> @@ -158,7 +162,7 @@ </when> </conditional> - <param name="unkn" type="text" value="1:5" label="EIC_Unknown" help="vector of peaks number to be plotted, for example 1:5 (mean 1 to 5) or 1,4,12 means 1 4 and 12). For all EIC use 0" /> + <param name="unkn" type="text" value="1:5" label="EIC_Unknown" help="vector of peaks number to be plotted, for example 1:5 (mean 1 to 5) or 1,4,12 means 1 4 and 12). For all EIC use 0. none for no EIC plot" /> <conditional name="options_rifilter"> <param name="option" type="select" label="Use RI as filter" > <option value="false" selected="true">FALSE</option> @@ -236,6 +240,7 @@ Description ----------- metaMS.runGC is a function dedicated to GCMS data processing from converted files to the generation of pseudospectra (compounds) table. +Current version for metaMS R package: 1.8.0 **Process:** Each of the converted data (cdf, mzML...) is profiled by a combination of xcms and CAMERA functions. Then all the mass spectra of detected peaks are compared and clustered. @@ -364,6 +369,11 @@ Changelog/News -------------- +**Version 2.1 - 08/06/2017** + +- Quality: add sessionInfo logs with packages versions +- Processing: add RI usage + **Version 1.1 - 11/07/2016** - TEST: refactoring to pass planemo test using conda dependencies