Mercurial > repos > lecorguille > xcms_plot_chromatogram
diff xcms_plot_chromatogram.r @ 0:fe1f0f16d9e6 draft
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit cfb08142b6bfb78002b4e0d7775adb1a58e66c33-dirty
author | lecorguille |
---|---|
date | Thu, 08 Mar 2018 02:48:44 -0500 |
parents | |
children | e6fdadaf039e |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xcms_plot_chromatogram.r Thu Mar 08 02:48:44 2018 -0500 @@ -0,0 +1,82 @@ +#!/usr/bin/env Rscript + +# ----- LOG FILE ----- +log_file=file("log.txt", open = "wt") +sink(log_file) +sink(log_file, type = "output") + + +# ----- PACKAGE ----- +cat("\tSESSION INFO\n") + +#Import the different functions +source_local <- function(fname){ argv <- commandArgs(trailingOnly=FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) } +source_local("lib.r") + +pkgs <- c("xcms","batch","RColorBrewer") +loadAndDisplayPackages(pkgs) +cat("\n\n"); + + +# ----- ARGUMENTS ----- +cat("\tARGUMENTS INFO\n") +args = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects +write.table(as.matrix(args), col.names=F, quote=F, sep='\t') + +cat("\n\n") + +# ----- PROCESSING INFILE ----- +cat("\tARGUMENTS PROCESSING INFO\n") + +#saving the specific parameters +method <- args$method; args$method <- NULL + +cat("\n\n") + + +# ----- ARGUMENTS PROCESSING ----- +cat("\tINFILE PROCESSING INFO\n") + +#image is an .RData file necessary to use xset variable given by previous tools +load(args$image); args$image=NULL +if (!exists("xdata")) stop("\n\nERROR: The RData doesn't contain any object called 'xdata'. This RData should have been created by an old version of XMCS 2.*") + +# Handle infiles +if (!exists("singlefile")) singlefile <- NULL +if (!exists("zipfile")) zipfile <- NULL +rawFilePath <- getRawfilePathFromArguments(singlefile, zipfile, args) +zipfile <- rawFilePath$zipfile +singlefile <- rawFilePath$singlefile +args <- rawFilePath$args +directory <- retrieveRawfileInTheWorkingDirectory(singlefile, zipfile) + + +cat("\n\n") + + +# ----- MAIN PROCESSING INFO ----- +cat("\tMAIN PROCESSING INFO\n") + + +cat("\t\tDRAW GRAPHICS\n") + +#@TODO: one day, use xdata instead of xset to draw the TICs and BPC or a complete other method +getPlotTICs(xdata, pdfname="TICs.pdf") +getPlotBPIs(xdata, pdfname="BPIs.pdf") + +cat("\n\n") + +# ----- EXPORT ----- + +cat("\tXCMSnExp OBJECT INFO\n") +print(xdata) +cat("\n\n") + +cat("\txcmsSet OBJECT INFO\n") +# Get the legacy xcmsSet object +xset <- getxcmsSetObject(xdata) +print(xset) +cat("\n\n") + + +cat("\tDONE\n")