From 35ec27602fd68b7de278239fbaf686e6a8e6683e Mon Sep 17 00:00:00 2001 From: gabrielctn Date: Sun, 8 Apr 2018 17:48:21 +0200 Subject: [PATCH 1/9] Small snippet of code to handle error messages in Galaxy --- galaxy/ipo/ipo4retgroup.r | 2 ++ 1 file changed, 2 insertions(+) diff --git a/galaxy/ipo/ipo4retgroup.r b/galaxy/ipo/ipo4retgroup.r index a6d94d1..7ba126c 100755 --- a/galaxy/ipo/ipo4retgroup.r +++ b/galaxy/ipo/ipo4retgroup.r @@ -1,6 +1,8 @@ #!/usr/bin/env Rscript #Authors Gildas Le Corguille and Yann Guitton +# Setup R error handling to go to stderr for better error messages in Galaxy +options(show.error.messages=F, error=function(){cat(geterrmessage(),file=stderr());q("no",1,F)}) # ----- LOG FILE ----- log_file=file("log.txt", open = "wt") From 095b7e30f8d1a273050e81dbe6d36f9c8405c9fd Mon Sep 17 00:00:00 2001 From: gabrielctn Date: Sun, 8 Apr 2018 17:50:27 +0200 Subject: [PATCH 2/9] Removed input path comma parsing because some paths may have comma inside --- galaxy/ipo/ipo4retgroup.r | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/galaxy/ipo/ipo4retgroup.r b/galaxy/ipo/ipo4retgroup.r index 7ba126c..1179f73 100755 --- a/galaxy/ipo/ipo4retgroup.r +++ b/galaxy/ipo/ipo4retgroup.r @@ -44,8 +44,6 @@ source_local("lib.r") cat("\n\n") -#Import the different functions - # ----- PROCESSING INFILE ----- cat("\tARGUMENTS PROCESSING INFO\n") @@ -70,8 +68,8 @@ if (!is.null(listArguments[["zipfile"]])){ if (!is.null(listArguments[["singlefile_galaxyPath"]])){ - singlefile_galaxyPath = unlist(strsplit(listArguments[["singlefile_galaxyPath"]],",")); listArguments[["singlefile_galaxyPath"]]=NULL - singlefile_sampleName = unlist(strsplit(listArguments[["singlefile_sampleName"]],",")); listArguments[["singlefile_sampleName"]]=NULL + singlefile_galaxyPath = listArguments[["singlefile_galaxyPath"]]; listArguments[["singlefile_galaxyPath"]]=NULL + singlefile_sampleName = listArguments[["singlefile_sampleName"]]; listArguments[["singlefile_sampleName"]]=NULL } # single file case From 54e47fcfbdeb4c44b3129a3266fd22186d2b597b Mon Sep 17 00:00:00 2001 From: gabrielctn Date: Sun, 8 Apr 2018 17:51:22 +0200 Subject: [PATCH 3/9] Added missing file input in Galaxy wrapper ipo4retgroup --- galaxy/ipo/ipo4retgroup.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/galaxy/ipo/ipo4retgroup.xml b/galaxy/ipo/ipo4retgroup.xml index 8ad8653..7250d00 100644 --- a/galaxy/ipo/ipo4retgroup.xml +++ b/galaxy/ipo/ipo4retgroup.xml @@ -21,6 +21,12 @@ LANG=C Rscript $__tool_directory__/ipo4retgroup.r image '$image' + + #if $input.is_of_type("mzxml") or $input.is_of_type("mzml") or $input.is_of_type("mzdata") or $input.is_of_type("netcdf"): + singlefile_galaxyPath '$input' singlefile_sampleName '$input.name' + #else + zipfile '$input' + #end if parametersOutput '$parametersOutput' @@ -63,6 +69,8 @@ ]]> + + From e31be39bf3bceff009e95abda914343aa56dda5a Mon Sep 17 00:00:00 2001 From: gabrielctn Date: Sun, 8 Apr 2018 17:54:22 +0200 Subject: [PATCH 4/9] Fixed missing level in command line for retcor method --- galaxy/ipo/ipo4retgroup.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/galaxy/ipo/ipo4retgroup.xml b/galaxy/ipo/ipo4retgroup.xml index 7250d00..7814af0 100644 --- a/galaxy/ipo/ipo4retgroup.xml +++ b/galaxy/ipo/ipo4retgroup.xml @@ -47,11 +47,11 @@ ## retcor methods - #if $retcor.methods.method == "obiwarp": + #if $retcor.methods.retcormethod == "obiwarp": retcorMethod obiwarp - profStep $methods.section_retcor_obiwarp_non_optimizable.profStep + profStep $retcor.methods.section_retcor_obiwarp_non_optimizable.profStep - #elif $retcor.methods.method == "peakgroups": + #elif $retcor.methods.retcormethod == "peakgroups": retcorMethod loess smooth $retcor.methods.section_retcor_peakgroups_non_optimizable.smooth extra $retcor.methods.section_retcor_peakgroups_non_optimizable.extra @@ -59,7 +59,7 @@ span $retcor.methods.section_retcor_peakgroups_non_optimizable.span family $retcor.methods.section_retcor_peakgroups_non_optimizable.family plottype $retcor.methods.section_retcor_peakgroups_non_optimizable.plottype - #elif $retcor.methods.method == "none": + #elif $retcor.methods.retcormethod == "none": retcorMethod none #end if From 74c3e6d313f6f2a3b0892cc86e554a9613548449 Mon Sep 17 00:00:00 2001 From: gabrielctn Date: Sun, 8 Apr 2018 17:54:50 +0200 Subject: [PATCH 5/9] Handel error for Galaxy --- galaxy/ipo/ipo4xcmsSet.r | 2 ++ 1 file changed, 2 insertions(+) diff --git a/galaxy/ipo/ipo4xcmsSet.r b/galaxy/ipo/ipo4xcmsSet.r index 4851b75..a4aead0 100755 --- a/galaxy/ipo/ipo4xcmsSet.r +++ b/galaxy/ipo/ipo4xcmsSet.r @@ -1,6 +1,8 @@ #!/usr/bin/env Rscript #Authors Gildas Le Corguille and Yann Guitton +# Setup R error handling to go to stderr for better error messages in Galaxy +options(show.error.messages=F, error=function(){cat(geterrmessage(),file=stderr());q("no",1,F)}) # ----- LOG FILE ----- log_file=file("log.txt", open = "wt") From 22dc8e5044d7250b96a2159d2454c1c7e0fd62a5 Mon Sep 17 00:00:00 2001 From: gabrielctn Date: Sun, 8 Apr 2018 18:14:51 +0200 Subject: [PATCH 6/9] Fix unzip method to make it work also on linux making it more general --- galaxy/ipo/ipo4xcmsSet.r | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/galaxy/ipo/ipo4xcmsSet.r b/galaxy/ipo/ipo4xcmsSet.r index a4aead0..639dbd1 100755 --- a/galaxy/ipo/ipo4xcmsSet.r +++ b/galaxy/ipo/ipo4xcmsSet.r @@ -20,7 +20,7 @@ for(pkg in pkgs) { cat(pkg,"\t",as.character(packageVersion(pkg)),"\n",sep="") } source_local <- function(fname){ argv <- commandArgs(trailingOnly = FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) } -cat("\n\n"); +cat("\n\n"); @@ -84,15 +84,15 @@ if(exists("singlefile_galaxyPath") && (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) } - + cwd=getwd() dir.create("raw") setwd("raw") file.symlink(singlefile_galaxyPath,singlefile_sampleName) setwd(cwd) - + directory = "raw" - + } # We unzip automatically the chromatograms from the zip files. @@ -111,7 +111,7 @@ if(exists("zipfile") && (zipfile!="")) { setwd("ipoworkingdir") #unzip - suppressWarnings(unzip(zipfile, unzip="unzip")) + suppressWarnings(unzip(zipfile, unzip=getOption("unzip"))) #get the directory name filesInZip=unzip(zipfile, list=T); @@ -162,4 +162,3 @@ cat("\n\n") cat("\tDONE\n") - From 06b079deef2cc4491297f7e8e2d942c611596797 Mon Sep 17 00:00:00 2001 From: gabrielctn Date: Sun, 8 Apr 2018 18:16:18 +0200 Subject: [PATCH 7/9] Added getInfos(mzfiles) function to complete output results --- galaxy/ipo/lib.r | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/galaxy/ipo/lib.r b/galaxy/ipo/lib.r index 42c499a..5986fa4 100644 --- a/galaxy/ipo/lib.r +++ b/galaxy/ipo/lib.r @@ -1,3 +1,22 @@ +getInfos = function(mzdatafiles){ + + # Get informations about instruments used and run + file.format = c("mzData", "mzdata") + if(tools::file_ext(mzdatafiles) %in% file.format){ + ms = openMSfile(mzdatafiles, backend="Ramp") + } else { + ms = openMSfile(mzdatafiles) + } + + runInfo = t(sapply(runInfo(ms), function(x) x[1], USE.NAMES=TRUE)) + instrumentInfo = t(sapply(instrumentInfo(ms), function(x) x, USE.NAMES=TRUE)) + + infos = list("runinfo" = runInfo, "instrumentInfo" = instrumentInfo) + return (infos) +} + + + ## ## This function launch IPO functions to get the best parameters for xcmsSet ## A sample among the whole dataset is used to save time @@ -32,13 +51,35 @@ ipo4xcmsSet = function(directory, parametersOutput, listArguments, samplebyclass # filter listArguments to only get releavant parameters and complete with those that are not declared peakpickingParametersUser = c(listArguments[names(listArguments) %in% names(peakpickingParameters)], peakpickingParameters[!(names(peakpickingParameters) %in% names(listArguments))]) peakpickingParametersUser$verbose.columns = TRUE + + # allow range for min and max peakwidth and ppm if given in arguments + if (!is.null(listArguments[["minPeakWidth"]])){ + peakpickingParametersUser$min_peakwidth = as.vector(as.numeric(unlist(strsplit(listArguments[["minPeakWidth"]],split = ",")))) + listArguments[["minPeakWidth"]] = NULL + } + + if (!is.null(listArguments[["maxPeakWidth"]])){ + peakpickingParametersUser$max_peakwidth = as.vector(as.numeric(unlist(strsplit(listArguments[["maxPeakWidth"]],split = ",")))) + listArguments[["maxPeakWidth"]] = NULL + } + + if (!is.null(listArguments[["ppm"]])){ + if(grepl(",", listArguments[["ppm"]])) + peakpickingParametersUser$ppm = as.vector(as.numeric(unlist(strsplit(listArguments[["ppm"]],split = ",")))) + else + peakpickingParametersUser$ppm = listArguments[["ppm"]] + listArguments[["ppm"]] = NULL + } #peakpickingParametersUser$profparam <- list(step=0.005) #not yet used by IPO have to think of it for futur improvement resultPeakpicking = optimizeXcmsSet(mzmlfile, peakpickingParametersUser, nSlaves=peakpickingParametersUser$nSlaves, subdir="../IPO_results") #some images generated by IPO - # export - resultPeakpicking_best_settings_parameters = resultPeakpicking$best_settings$parameters[!(names(resultPeakpicking$best_settings$parameters) %in% c("nSlaves","verbose.columns"))] - write.table(t(as.data.frame(resultPeakpicking_best_settings_parameters)), file=parametersOutput, sep="\t", row.names=T, col.names=F, quote=F) #can be read by user + # export results + resultPeakpicking_best_settings_parameters = resultPeakpicking$best_settings$parameters[!(names(resultPeakpicking$best_settings$parameters) %in% c("nSlaves","verbose.columns"))] + + infos = getInfos(mzmlfile) + # Write results in table with machine and run infos + write.table(cbind(mzmlfile, infos$instrumentInfo, infos$runInfo, t(as.matrix(resultPeakpicking_best_settings_parameters))), file=parametersOutput, sep="\t", row.names=F, col.names=T, quote=F) return (resultPeakpicking$best_settings$xset) } From fd6625d3f87552f17b5a82a92afd96ab70a510e3 Mon Sep 17 00:00:00 2001 From: Gabriel Cretin Date: Mon, 9 Apr 2018 10:16:11 +0200 Subject: [PATCH 8/9] Set obiwarp as default retcor.method If not selected by default, Travis shouts that the method cannot be found --- galaxy/ipo/ipo4retgroup.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/galaxy/ipo/ipo4retgroup.xml b/galaxy/ipo/ipo4retgroup.xml index 7814af0..677757e 100644 --- a/galaxy/ipo/ipo4retgroup.xml +++ b/galaxy/ipo/ipo4retgroup.xml @@ -113,7 +113,7 @@
- + From 042077ca9abd5c9fa953ceefc727545e57beb805 Mon Sep 17 00:00:00 2001 From: Gabriel Cretin Date: Mon, 9 Apr 2018 11:09:42 +0200 Subject: [PATCH 9/9] Change name method to retcormethod --- galaxy/ipo/ipo4retgroup.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/galaxy/ipo/ipo4retgroup.xml b/galaxy/ipo/ipo4retgroup.xml index 677757e..ac5528d 100644 --- a/galaxy/ipo/ipo4retgroup.xml +++ b/galaxy/ipo/ipo4retgroup.xml @@ -112,7 +112,7 @@
- + @@ -187,7 +187,7 @@
- +