comparison xcms_plot_chromatogram.r @ 13:024974037c4e draft

"planemo upload for repository https://github.com/workflow4metabolomics/xcms commit dcc90f9cf76e6980c0a7d9698c89fab826e7adae"
author workflow4metabolomics
date Wed, 07 Apr 2021 12:07:49 +0000
parents dbd877060ac3
children 8846a03995d3
comparison
equal deleted inserted replaced
12:0cab69429e1e 13:024974037c4e
3 3
4 # ----- PACKAGE ----- 4 # ----- PACKAGE -----
5 cat("\tSESSION INFO\n") 5 cat("\tSESSION INFO\n")
6 6
7 #Import the different functions 7 #Import the different functions
8 source_local <- function(fname){ argv <- commandArgs(trailingOnly=FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) } 8 source_local <- function(fname) {
9 argv <- commandArgs(trailingOnly = FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep = "/"))
10 }
9 source_local("lib.r") 11 source_local("lib.r")
10 12
11 pkgs <- c("xcms","batch","RColorBrewer") 13 pkgs <- c("xcms", "batch", "RColorBrewer")
12 loadAndDisplayPackages(pkgs) 14 loadAndDisplayPackages(pkgs)
13 cat("\n\n"); 15 cat("\n\n");
14 16
15 17
16 # ----- ARGUMENTS ----- 18 # ----- ARGUMENTS -----
17 cat("\tARGUMENTS INFO\n") 19 cat("\tARGUMENTS INFO\n")
18 args = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects 20 args <- parseCommandArgs(evaluate = FALSE) #interpretation of arguments given in command line as an R list of objects
19 write.table(as.matrix(args), col.names=F, quote=F, sep='\t') 21 write.table(as.matrix(args), col.names = F, quote = F, sep = "\t")
20 22
21 cat("\n\n") 23 cat("\n\n")
22 24
23 # ----- PROCESSING INFILE ----- 25 # ----- PROCESSING INFILE -----
24 cat("\tARGUMENTS PROCESSING INFO\n") 26 cat("\tARGUMENTS PROCESSING INFO\n")
47 49
48 50
49 cat("\t\tDRAW GRAPHICS\n") 51 cat("\t\tDRAW GRAPHICS\n")
50 52
51 register(SerialParam()) 53 register(SerialParam())
52 if (!exists("chromTIC") || is.null(chromTIC)) { cat("\t\t\tCompute TIC\n"); chromTIC <- chromatogram(xdata, aggregationFun = "sum") } 54 if (!exists("chromTIC") || is.null(chromTIC)) {
53 if (!exists("chromBPI") || is.null(chromBPI)) { cat("\t\t\tCompute BPI\n"); chromBPI <- chromatogram(xdata, aggregationFun = "max") } 55 cat("\t\t\tCompute TIC\n"); chromTIC <- chromatogram(xdata, aggregationFun = "sum")
56 }
57 if (!exists("chromBPI") || is.null(chromBPI)) {
58 cat("\t\t\tCompute BPI\n"); chromBPI <- chromatogram(xdata, aggregationFun = "max")
59 }
54 60
55 if (!is.null(chromTIC_adjusted)) chromTIC <- chromTIC_adjusted 61 if (!is.null(chromTIC_adjusted)) chromTIC <- chromTIC_adjusted
56 if (!is.null(chromBPI_adjusted)) chromBPI <- chromBPI_adjusted 62 if (!is.null(chromBPI_adjusted)) chromBPI <- chromBPI_adjusted
57 63
58 getPlotChromatogram(chromTIC, xdata, pdfname="TICs.pdf", aggregationFun = "sum") 64 getPlotChromatogram(chromTIC, xdata, pdfname = "TICs.pdf", aggregationFun = "sum")
59 getPlotChromatogram(chromBPI, xdata, pdfname="BPIs.pdf", aggregationFun = "max") 65 getPlotChromatogram(chromBPI, xdata, pdfname = "BPIs.pdf", aggregationFun = "max")
60 66
61 cat("\n\n") 67 cat("\n\n")
62 68
63 # ----- EXPORT ----- 69 # ----- EXPORT -----
64 70
65 cat("\tXCMSnExp OBJECT INFO\n") 71 cat("\tXCMSnExp OBJECT INFO\n")
66 print(xdata) 72 print(xdata)
67 cat("\n\n") 73 cat("\n\n")
68 74
69 # 2020-01-17 - disable because xcms 3.4.4 raises an error with xdata build with xcms 3.6.1
70 #cat("\txcmsSet OBJECT INFO\n")
71 # Get the legacy xcmsSet object
72 #xset <- getxcmsSetObject(xdata)
73 #print(xset)
74 #cat("\n\n")
75
76 75
77 cat("\tDONE\n") 76 cat("\tDONE\n")