# HG changeset patch
# User mish
# Date 1377701329 14400
# Node ID da7f0718a876870e49eb4e8711879fc7621fd7a8
Uploaded
diff -r 000000000000 -r da7f0718a876 README.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/README.txt Wed Aug 28 10:48:49 2013 -0400
@@ -0,0 +1,31 @@
+
+-----------------------------------------------------------------------
+ XCMS Suite datatypes: A Workflow for metabolomics by ABIMS team
+-----------------------------------------------------------------------
+
+This package contains the tools for the XCMS suite.
+
+--------------------------------------------------------------------
+Instructions for integration of the XCMS Suite tools into the workflow-system
+Galaxy (http://getgalaxy.org)
+--------------------------------------------------------------------
+
+For installing the tools of the XCMS Suite into your Galaxy installation, please do the following:
+
+
+ - Download and follow the instructions for installing the XCMS Suite datatypes (http://misharl@toolsheddev.sb-roscoff.fr/repos/misharl/xcms_datatypes).
+
+ -R libraries needed for the script xcms.r used by all the XCMS tools:
+ library(xcms)
+ library(batch) #necessary for parseCommandArgs function
+ library(CAMERA)
+
+
+ - Set up the "--file" parameter (absolute path of the xcms.r used by all tools) in all XML tools (XCMS_R_DIR for the "--file" parameter)
+ --file=/XCMS_R_DIR/xcms.r
+
+ - Set up the tcis.r directory location (TCIS_R_DIR) in the script xcms.r:
+ source("/TCIS_R_DIR/tcis.r")
+
+
+Last but not least, restart Galaxy.
diff -r 000000000000 -r da7f0718a876 repository_dependencies.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/repository_dependencies.xml Wed Aug 28 10:48:49 2013 -0400
@@ -0,0 +1,4 @@
+
+
+
+
diff -r 000000000000 -r da7f0718a876 static/images/xcms_workflow.png
Binary file static/images/xcms_workflow.png has changed
diff -r 000000000000 -r da7f0718a876 xcms/abims_CAMERA_annotateDiffreport.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xcms/abims_CAMERA_annotateDiffreport.xml Wed Aug 28 10:48:49 2013 -0400
@@ -0,0 +1,152 @@
+
+
+ Wrapper function for the xcms diffreport and the annotate function. Returns a diffreport within the annotation results.
+
+
+ R --vanilla --no-site-file --file=/XCMS_R_DIR/xcms.r --args xfunction annotateDiffreport image $image input $input
+ eicmax $eicmax eicwidth $eicwidth metlin $metlin sortpval $sortpval
+ nSlaves $nSlaves
+ sigma $sigma perfwhm $perfwhm
+ maxcharge $maxcharge maxiso $maxiso minfrac $minfrac
+ ppm $ppm mzabs $mzabs
+ #quick "TRUE"
+
+ quick $quick_block.quick
+ #if $quick_block.quick == "FALSE"
+ cor_eic_th $quick_block.cor_eic_th graphMethod $quick_block.graphMethod pval $quick_block.pval calcCiS $quick_block.calcCiS calcIso $quick_block.calcIso calcCaS $quick_block.calcCaS
+ polarity $quick_block.polarity multiplier $quick_block.multiplier
+ #end if
+
+ #if $options.option == "show":
+ value "$options.intval"
+ h $options.h
+ w $options.w
+ mzdec $options.mzdec
+ max_peaks $options.max_peaks
+ #end if
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+**CAMERA package**
+
+The R-package CAMERA is a Collection of Algorithms for MEtabolite
+pRofile Annotation. Its primary purpose is the annotation and evaluation of
+LC-MS data. It includes algorithms for annotation of isotope peaks, adducts
+and fragments in peak lists. Additional methods cluster mass signals that
+originate from a single metabolite, based on rules for mass differences and
+peak shape comparison. To use the strength of already existing programs,
+CAMERA is designed to interact directly with processed peak data from the
+R-package **xcms**.
+
+**What it does?**
+
+The CAMERA annotation procedure can be split into two parts: We want to
+answer the questions which peaks occur from the same molecule and secondly
+compute its exact mass and annotate the ion species. Therefore CAMERA
+annotation workflow contains following primary functions:
+1. peak grouping after retention time (**groupFWHM**)
+2. peak group verification with peakshape correlation (**groupCorr**)
+Both methods separate peaks into different groups, which we define as ”pseu-
+dospectra”. Those pseudospectra can consists from one up to 100 ions, de-
+pending on the molecules amount and ionizability. Afterwards the exposure
+of the ion species can be performed with:
+2
+1. annotation of possible isotopes (**findIsotopes**)
+2. annotation of adducts and calculating hypothetical masses for the group
+(**findAdducts**)
+This workflow results in a **data-frame** similar to a xcms peak table, that can
+be easily stored in a comma separated table .csv (Excel-readable)
+
+The **annotateDiffreport** returns an **diffreport**, see diffreport, within additional columns containing the annotation results.
+
+------
+
+CAMERA needs as input an xcmsSet object that is processed with your
+favorite parameters
+
+Put in the .RData file generated by **fillPeaks** and **.mz.zip** source file
+
+------
+
+.. class:: infomark
+
+The output file is an group.RData file.
+
+You can continue your analysis using it in **CAMERA** package tools.
+
+diffreport.zip file contains filebase_eic and filebase_box directories and filebase.tsv file : results of analysis
+
+
+
+
+
diff -r 000000000000 -r da7f0718a876 xcms/abims_xcms_diffreport.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xcms/abims_xcms_diffreport.xml Wed Aug 28 10:48:49 2013 -0400
@@ -0,0 +1,115 @@
+
+
+ A report showing the most statistically significant differences in analyte intensities
+
+
+ R --vanilla --no-site-file --file=/XCMS_R_DIR/xcms.r --args xfunction diffreport image $image input $input eicmax $eicmax eicwidth $eicwidth metlin $metlin sortpval $sortpval
+ #if $options.option == "show":
+ value "$options.value"
+ h $options.h
+ w $options.w
+ mzdec $options.mzdec
+ #end if
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+**What it does?**
+
+Create a report showing the most significant differences between
+two sets of samples. Optionally create extracted ion chromatograms
+for the most significant differences.
+
+This method handles creation of summary reports with statistics
+about which analytes were most significantly different between two
+sets of samples. It computes Welch's two-sample t-statistic for
+each analyte and ranks them by p-value. It returns a summary
+report that can optionally be written out to a tab-separated file.
+
+Additionally, it does all the heavy lifting involved in creating
+superimposed extracted ion chromatograms for a given number of
+analytes. It does so by reading the raw data files associated
+with the samples of interest one at a time. As it does so, it
+prints the name of the sample it is currently reading. Depending
+on the number and size of the samples, this process can take a
+long time.
+
+If a base file name is provided, the report (see Value section)
+will be saved to a tab separated file. If EICs are generated, they
+will be saved as 640x480 PNG files in a newly created
+
+------
+
+**Parameters**
+
+**eicmax**
+
+It will automatically generate extracted ion chro-
+matograms for a given number of them
+
+**metlin**
+
+If the metlin argument is set to a numeric value, the report will include links
+to the Metlin Metabolite Database (http://metlin.scripps.edu/) showing potential
+metabolite identities. A positive value indicates the data was acquired in positive ion
+mode and the neutral mass is calculated assuming all ions are M+H. A negative value
+does the opposite. The value itself indicates the uncertainty in mass accuracy.
+
+**value**
+
+If ‘value="into"’, integrated peak intensities are used.
+
+If ‘value="maxo"’, maximum peak intensities are used.
+
+If ‘value="intb"’, baseline corrected integrated peak intensities are used (only available if peak detection was done by ‘findPeaks.centWave’).
+
+------
+
+.. class:: infomark
+
+The output file is an group.RData file.
+
+You can continue your analysis using it in **CAMERA** package tools.
+
+diffreport.zip file contains filebase_eic and filebase_box directories and filebase.tsv file : results of analysis
+
+
+
diff -r 000000000000 -r da7f0718a876 xcms/abims_xcms_fillPeaks.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xcms/abims_xcms_fillPeaks.xml Wed Aug 28 10:48:49 2013 -0400
@@ -0,0 +1,85 @@
+
+
+
+ R
+
+
+ Integrate the signal in the region of that peak group not represented and create a new peak
+
+
+ R --vanilla --no-site-file --file=/XCMS_R_DIR/xcms.r --args xfunction fillPeaks image $image input $input method $method
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+**What it does?**
+
+For each sample, identify peak groups where that sample is not
+represented. For each of those peak groups, integrate the signal
+in the region of that peak group and create a new peak.
+
+According to the type of raw-data there are 2
+different methods available. for filling gcms/lcms data the method
+"chrom" integrates raw-data in the chromatographic domain, whereas
+"MSW" is used for peaklists without retention-time information
+like those from direct-infusion spectra.
+
+------
+
+**Methods**
+
+-**chrom**
+
+This method produces intensity values for those missing samples
+by integrating raw data in peak
+group region. In a given group, the start and ending retention
+time points for integration are defined by the median start and
+end points of the other detected peaks. The start and end m/z
+values are similarly determined. Intensities can be still be zero,
+which is a rather unusual intensity for a peak. This is the case
+if e.g. the raw data was threshholded, and the integration area
+contains no actual raw intensities, or if one sample is
+miscalibrated, such thet the raw data points are (just) outside
+the integration area.
+
+Importantly, if retention time correction data is available, the
+alignment information is used to more precisely integrate the
+propper region of the raw data. If the corrected retention time is
+beyond the end of the raw data, the value will be not-a-number (NaN).
+
+-**MSW**
+
+After peak grouping, there will always be peak groups that do not
+include peaks from every sample. This method produces intensity
+values for those missing samples by integrating raw data in peak
+group region. In a given group, the start and ending m/z values
+for integration are defined by the median start and end points of
+the other detected peaks
+
+------
+
+.. class:: infomark
+
+The output file is an group.RData file. You can continue your analysis using it in **diffreport** tool.
+
+
+
diff -r 000000000000 -r da7f0718a876 xcms/abims_xcms_group.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xcms/abims_xcms_group.xml Wed Aug 28 10:48:49 2013 -0400
@@ -0,0 +1,142 @@
+
+
+
+ R
+
+
+ Group peaks together across samples using overlapping m/z bins and calculation of smoothed peak distributions in chromatographic time.
+
+
+ R --vanilla --file=/XCMS_R_DIR/xcms.r --quiet --no-site-file --args xfunction group image $image method $methods.method sleep 0.001
+ #if $methods.method == "density":
+ ## minsamp $methods.minsamp
+ minfrac $methods.minfrac
+ bw $methods.bw
+ mzwid $methods.mzwid
+ #elif $methods.method == "mzClust":
+ mzppm $methods.mzppm
+ mzabs $methods.mzabs
+ minfrac $methods.minfrac
+ ## minsamp $methods.minsamp
+ #else:
+ mzVsRTbalance $methods.mzVsRTbalance
+ mzCheck $methods.mzCheck
+ rtCheck $methods.rtCheck
+ kNN $methods.kNN
+ #end if
+ #if $options.option == "show":
+ max $options.max
+ #end if
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+**What it does?**
+
+Returns a new xcmsSet object with the additional group information.
+
+Allows rejection of features, which are only partially detected within the replicates of a sample class. In addition to the intensity matrix, separate columns containing information related to the the presence of a feature within a sample class are generated and have proven useful in further filtering steps. It should be noted, that each alignement has to be evaluated in therms of quality prior to any further analysis.
+
+------
+
+**Parameters**
+
+There are several grouping parameters to consider optimizing for your chromatography and mass spectrometer.
+
+**method**
+
+"mzClust" Runs high resolution alignment on single spectra samples stored in a given xcmsSet
+
+"density" groups peaks together across samples using overlapping m/z bins and calculation of smoothed peak distributions in chromatographic time
+
+"nearest" groups peaks together across samples by creating a master peak list and assigning corresponding peaks from all samples. It is inspired by the alignment algorithm of mzMine.
+
+
+Use the **sleep** argument to specify a time (in seconds) to pause and plot each iteration. That can be quite useful for
+visualizing parameter effects.
+
+
+------
+
+.. class:: infomark
+
+The output file is an group.RData file. You can continue your analysis using it in **retcor** or **fillPeaks** tool.
+
+
+
diff -r 000000000000 -r da7f0718a876 xcms/abims_xcms_retcor.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xcms/abims_xcms_retcor.xml Wed Aug 28 10:48:49 2013 -0400
@@ -0,0 +1,115 @@
+
+
+
+ R
+
+
+ Retention Time Correction using retcor function from xcms R package
+
+
+ R --vanilla --slave --no-site-file --file=/XCMS_R_DIR/xcms.r --args input $input image $image xfunction retcor method $methods.method
+ #if $methods.method == "obiwarp":
+ profStep $methods.profStep
+ #else
+ smooth $methods.smooth
+ extra $methods.extra
+ missing $methods.missing
+ #if $methods.options.option == "show":
+ span $methods.options.span
+ family $methods.options.family
+ plottype $methods.options.plottype
+ #end if
+ #end if
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ (methods['method'] == 'peakgroups')
+ (options['option'] == 'show')
+ (family == 'symmetric')
+ (plottype != 'none')
+
+
+
+
+
+
+
+
+
+
+
+
+**What it does?**
+
+After matching peaks into groups, xcms can use those groups to identify and correct
+correlated drifts in retention time from run to run. The aligned peaks can then be
+used for a second pass of peak grouping which will be more accurate than the first.
+The whole process can be repeated in an iterative fashion. Not all peak groups will be helpful
+for identifying retention time drifts. Some groups may be missing peaks from a large
+fraction of samples and thus provide an incomplete picture of the drift at that time point.
+Still others may contain multiple peaks from the same sample, which is a sign of impropper grouping.
+
+It returns an xcms-Set object with corrected retention times
+
+------
+
+**Parameters**
+
+xcms ignores those groups by only considering well-behaved peak groups which are missing at most one sample and
+have at most one extra peak. (Those values can be changed with the **missing** and **extra** arguments.)
+
+For each of those well-behaved groups, the algorithm calculates a median retention
+time and, for every sample, a deviation from that median. Within a sample, the observed deviation
+generally changes over time in a nonlinear fashion. Those changes are
+approximated using a local polynomial regression technique implemented in the **loess**
+function. By default, the curve fitting is done using least-squares on all data points.
+However, it is possible to enable outlier detection and removal by setting the **family**
+argument to **symmetric**.
+
+------
+
+.. class:: infomark
+
+The output file is an group.RData file.
+
+After retention time correction, the initial peak grouping becomes invalid and is
+discarded. Therefore, the resulting object needs to be regrouped. Here, we decrease the
+inclusiveness of the grouping using the **bw** argument using the output file in **group** tool.
+
+
+
diff -r 000000000000 -r da7f0718a876 xcms/abims_xcms_xcmsSet.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xcms/abims_xcms_xcmsSet.xml Wed Aug 28 10:48:49 2013 -0400
@@ -0,0 +1,188 @@
+
+
+
+ R
+
+
+ Filtration and Peak Identification using xcmsSet function from xcms R package to preprocess LC/MS data for relative quantification and statistical analysis
+
+
+ R --vanilla --slave --no-site-file --file=/XCMS_R_DIR/xcms.r --args input $input xfunction xcmsSet
+ ## profmethod $profmethod
+ nSlaves 9 method $methods.method
+ #if $methods.method == "centWave":
+ ppm $methods.ppm
+ peakwidth "c($methods.peakwidth)"
+ #if $methods.options_c.option == "show":
+ mzdiff $methods.options_c.mzdiff
+ snthresh $methods.options_c.snthresh
+ integrate $methods.options_c.integrate
+ noise $methods.options_c.noise
+ prefilter "c($methods.options_c.prefilter)"
+ #end if
+ #elif $methods.method == "matchedFilter":
+ step $methods.step
+ fwhm $methods.fwhm
+ #if $methods.options_m.option == "show":
+ ## sigma "$methods.options_m.sigma"
+ max $methods.options_m.max
+ snthresh $methods.options_m.snthresh
+ ## mzdiff $methods.options_m.mzdiff
+ steps $methods.options_m.steps
+ ## sleep $methods.options_m.sleep
+ #end if
+ #elif $methods.method == "MSW":
+ snthr $methods.snthr
+ nearbyPeak $methods.nearbyPeak
+ winSize.noise $methods.winSize_noise
+ amp.Th $methods.amp_Th
+ scales "c($methods.scales)"
+ SNR_method "$methods.SNR_method "
+ #end if
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+** The ms_zip input file **
+
+The input file to the metabolomic workflow is a zip file containing all your conditions as sub-directories, with its extension renamed to ".ms.zip".
+This file can then be loaded in Galaxy using the "Get Data" tool. The file datatype should be "mz_zip".
+
+**What it does?**
+The class of objects used for preprocessing analyte data from multiple LC/MS files is xcmsSet. It stores peak lists and provides methods for grouping and aligning those peaks.
+
+-----
+
+**Parameters**
+
+The default arguments for xcmsSet should work acceptably in most cases. However, there are a number of parameters that may need to be optimized for a particular instrument or group of samples.
+
++ **Profmethod**
+
+ One way of thinking about that process is as a transformation of the data from being separate
+ lists of mass/intensity pairs (one list for each scan) to a matrix with rows representing
+ equally spaced masses and a column for each scan. Data transformed into such a matrix
+ is usually referred to as being in profile mode. To do so, each scan of unequally spaced
+ masses must be mapped onto a column of the final matrix. The algorithm used to do so
+ is selected using the **profmethod** argument and can be either **“bin”**, **“binlin”**, **“binlinbase”**,
+ or **“intlin”**.
+
+ **bin** - bins the intensity into the matrix cell closest to it in mas
+
+ **binlin** - same as bin except that it uses linear interpolation to fill in cells that otherwise would have been left at zero
+
+ **binlinbase** -used when an intensity threshold is set below which no mass/intensity values are recorded in continuum mode and the mass spectral signal falls below that threshold, so that simple linear interpolation will create artificially high background
+
+ **intlin** - uses integration and linear interpolation between mass/intensity pairs to determine the equally spaced intensity values
+
++ **Method**
+
+ **Matched Filter**
+
+ One parameter to consider is the Gaussian model peak width used for matched filtration,an integral part of the peak detection algorithm.
+ For a discussion of how model peak width affects the signal to noise ratio, see Danielsson et al. (2002).
+
+ **cent Wave**
+
+ This algorithm is most suitable for high resolution LC/{TOF,OrbiTrap,FTICR}-MS data in centroid mode.
+ Due to the fact that peak centroids are used, a binning step is not necessary.
+ The method is capable of detecting close-by-peaks and also overlapping peaks. Some efforts are made to detect the exact peak boundaries to get precise
+ peak integrals.
+
+ **MSW**
+
+ Wavelet based, used for direct infusion data.
+ Continuous wavelet transform (CWT) can be used to locate chromatographic peaks on different scales.
+
+-----
+
+.. class:: infomark
+
+The output file is an xcmsSet.RData file. You can continue your analysis using it in **group** tool what is recommended as next step.
+
+
+
diff -r 000000000000 -r da7f0718a876 xcms/tcis.r
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xcms/tcis.r Wed Aug 28 10:48:49 2013 -0400
@@ -0,0 +1,52 @@
+# tcis.r version 20130418
+
+getTIC <- function(file,rtcor=NULL) {
+ object <- xcmsRaw(file)
+ cbind(if (is.null(rtcor)) object@scantime else rtcor, rawEIC(object,mzrange=range(object@env$mz))$intensity)
+}
+
+##
+## overlay TIC from all files in current folder or from xcmsSet, create pdf
+##
+getTICs <- function(xcmsSet=NULL,files=NULL, pdfname="TICs.pdf",rt=c("raw","corrected")) {
+ if (is.null(xcmsSet)) {
+ 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 = "|")
+ if (is.null(files))
+ files <- getwd()
+ info <- file.info(files)
+ listed <- list.files(files[info$isdir], pattern = filepattern,
+ recursive = TRUE, full.names = TRUE)
+ files <- c(files[!info$isdir], listed)
+ } else {
+ files <- filepaths(xcmsSet)
+ }
+
+ N <- length(files)
+ TIC <- vector("list",N)
+
+ for (i in 1:N) {
+ cat(files[i],"\n")
+ if (!is.null(xcmsSet) && rt == "corrected")
+ rtcor <- xcmsSet@rt$corrected[[i]] else
+ rtcor <- NULL
+ TIC[[i]] <- getTIC(files[i],rtcor=rtcor)
+ }
+
+ pdf(pdfname,w=16,h=12)
+ cols <- rainbow(N)
+ lty = 1:N
+ pch = 1:N
+ xlim = range(sapply(TIC, function(x) range(x[,1])))
+ ylim = range(sapply(TIC, function(x) range(x[,2])))
+ plot(0, 0, type="n", xlim = xlim, ylim = ylim, main = "Total Ion Chromatograms", xlab = "Retention Time", ylab = "TIC")
+ for (i in 1:N) {
+ tic <- TIC[[i]]
+ points(tic[,1], tic[,2], col = cols[i], pch = pch[i], type="l")
+ }
+ legend("topright",paste(basename(files)), col = cols, lty = lty, pch = pch)
+ dev.off()
+
+ invisible(TIC)
+}
diff -r 000000000000 -r da7f0718a876 xcms/xcms.r
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xcms/xcms.r Wed Aug 28 10:48:49 2013 -0400
@@ -0,0 +1,87 @@
+# xcms.r version 20130418
+
+library(xcms)
+library(batch) #necessary for parseCommandArgs function
+library(CAMERA)
+
+source("/w/galaxy/tools/prod/abims/xcms.20130418/tcis.r")
+
+listArguments = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects
+print(listArguments)
+
+#image is an .RData file necessary to use xset variable given by previous tools
+if (!is.null(listArguments[["image"]])){
+ load(listArguments[["image"]])
+ listArguments[["image"]]=NULL
+}
+
+#saving the name of the function in a variable thefunction
+thefunction = listArguments[["xfunction"]]
+listArguments[["xfunction"]]=NULL #delete from the list of arguments
+
+#necessary to unzip .zip file uploaded to Galaxy
+#thanks to .zip file it's possible to upload many file as the same time conserving the tree hierarchy of directories
+if (!is.null(listArguments[["input"]])) {
+ directory=unzip(listArguments[["input"]])
+ if (thefunction == "xcmsSet") {
+ listArguments=append(list(directory), listArguments)
+ }
+ listArguments[["input"]]=NULL
+}
+
+#addition of xset object to the list of arguments in the first position
+if (length(ls(pattern="^xset$")) != 0){
+ listArguments=append(list(xset), listArguments)
+}
+
+#change the default display settings
+dev.new(width=16, height=12)
+if (thefunction == "group") {
+ par(mfrow=c(2,2))
+} else if (thefunction == "retcor") {
+#try to change the legend display
+#~ par(xpd=NA)
+#~ par(xpd=T, mar=par()$mar+c(0,0,0,4))
+}
+
+##################################
+if (thefunction %in% c("diffreport", "annotateDiffreport")) {
+ 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)){
+ listArguments[["class1"]]=classes[i]
+ listArguments[["class2"]]=classes[i+n]
+ listArguments[["filebase"]]=paste(listArguments[["class1"]],listArguments[["class2"]], sep="_vs_")
+ save.image(paste("debug","RData",sep="."))
+ diffreport = do.call(thefunction, listArguments)
+ }
+ }
+ }
+ system(paste('ls . | grep -e "tsv$" -e "box$" -e "eic$" | zip -r -@ "Xdiffreport.zip" '))
+ write.table(diffreport, sep="\t", quote=FALSE, col.names=NA, file="Xdiffreport.tsv")
+ statmatrix = diffreport[,(names(diffreport) %in% c("name", sampnames(xset)))]
+ write.table(statmatrix, sep="\t", quote=FALSE, row.names=FALSE, file="Xdiffreport.data_matrix.tsv")
+###
+} else {
+ #execution of the function "thefunction" with the parameters given in "listArguments"
+ xset = do.call(thefunction, listArguments)
+ print(xset)
+ #transform the files absolute pathways into relative pathways
+ xset@filepaths<-sub("^.*/database/job_working_directory/[0123456789]+/[0123456789]+/" ,"", xset@filepaths)
+}
+
+if (thefunction == "xcmsSet") {
+ write.table(xset@phenoData, sep="\t", quote=FALSE, col.names=NA, file="sample_info.tab")
+ getTICs(xcmsSet=xset, pdfname="TICs_raw.pdf",rt="raw")
+} else if (thefunction == "retcor") {
+ getTICs(xcmsSet=xset, pdfname="TICs_corrected.pdf",rt="corrected")
+}
+
+#delete the parameters to avoid the passage to the next tool in .RData image
+rm(listArguments)
+
+#saving R data in .Rdata file to save the variables used in the present tool
+save.image(paste(thefunction,"RData",sep="."))