comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:fe1f0f16d9e6
1 #!/usr/bin/env Rscript
2
3 # ----- LOG FILE -----
4 log_file=file("log.txt", open = "wt")
5 sink(log_file)
6 sink(log_file, type = "output")
7
8
9 # ----- PACKAGE -----
10 cat("\tSESSION INFO\n")
11
12 #Import the different functions
13 source_local <- function(fname){ argv <- commandArgs(trailingOnly=FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) }
14 source_local("lib.r")
15
16 pkgs <- c("xcms","batch","RColorBrewer")
17 loadAndDisplayPackages(pkgs)
18 cat("\n\n");
19
20
21 # ----- ARGUMENTS -----
22 cat("\tARGUMENTS INFO\n")
23 args = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects
24 write.table(as.matrix(args), col.names=F, quote=F, sep='\t')
25
26 cat("\n\n")
27
28 # ----- PROCESSING INFILE -----
29 cat("\tARGUMENTS PROCESSING INFO\n")
30
31 #saving the specific parameters
32 method <- args$method; args$method <- NULL
33
34 cat("\n\n")
35
36
37 # ----- ARGUMENTS PROCESSING -----
38 cat("\tINFILE PROCESSING INFO\n")
39
40 #image is an .RData file necessary to use xset variable given by previous tools
41 load(args$image); args$image=NULL
42 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.*")
43
44 # Handle infiles
45 if (!exists("singlefile")) singlefile <- NULL
46 if (!exists("zipfile")) zipfile <- NULL
47 rawFilePath <- getRawfilePathFromArguments(singlefile, zipfile, args)
48 zipfile <- rawFilePath$zipfile
49 singlefile <- rawFilePath$singlefile
50 args <- rawFilePath$args
51 directory <- retrieveRawfileInTheWorkingDirectory(singlefile, zipfile)
52
53
54 cat("\n\n")
55
56
57 # ----- MAIN PROCESSING INFO -----
58 cat("\tMAIN PROCESSING INFO\n")
59
60
61 cat("\t\tDRAW GRAPHICS\n")
62
63 #@TODO: one day, use xdata instead of xset to draw the TICs and BPC or a complete other method
64 getPlotTICs(xdata, pdfname="TICs.pdf")
65 getPlotBPIs(xdata, pdfname="BPIs.pdf")
66
67 cat("\n\n")
68
69 # ----- EXPORT -----
70
71 cat("\tXCMSnExp OBJECT INFO\n")
72 print(xdata)
73 cat("\n\n")
74
75 cat("\txcmsSet OBJECT INFO\n")
76 # Get the legacy xcmsSet object
77 xset <- getxcmsSetObject(xdata)
78 print(xset)
79 cat("\n\n")
80
81
82 cat("\tDONE\n")