comparison xcms_group.r @ 27:d45a786cbc40 draft

"planemo upload for repository https://github.com/workflow4metabolomics/xcms commit dcc90f9cf76e6980c0a7d9698c89fab826e7adae"
author workflow4metabolomics
date Wed, 07 Apr 2021 12:06:33 +0000
parents 761913919c21
children 2b676d5eb848
comparison
equal deleted inserted replaced
26:0d05d0458376 27:d45a786cbc40
1 #!/usr/bin/env Rscript 1 #!/usr/bin/env Rscript
2 2
3 # ----- LOG FILE ----- 3 # ----- LOG FILE -----
4 log_file=file("log.txt", open = "wt") 4 log_file <- file("log.txt", open = "wt")
5 sink(log_file) 5 sink(log_file)
6 sink(log_file, type = "output") 6 sink(log_file, type = "output")
7 7
8 8
9 # ----- PACKAGE ----- 9 # ----- PACKAGE -----
10 cat("\tSESSION INFO\n") 10 cat("\tSESSION INFO\n")
11 11
12 #Import the different functions 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="/")) } 13 source_local <- function(fname) {
14 argv <- commandArgs(trailingOnly = FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep = "/"))
15 }
14 source_local("lib.r") 16 source_local("lib.r")
15 17
16 pkgs <- c("xcms","batch","RColorBrewer") 18 pkgs <- c("xcms", "batch", "RColorBrewer")
17 loadAndDisplayPackages(pkgs) 19 loadAndDisplayPackages(pkgs)
18 cat("\n\n"); 20 cat("\n\n");
19 21
20 22
21 # ----- ARGUMENTS ----- 23 # ----- ARGUMENTS -----
22 cat("\tARGUMENTS INFO\n") 24 cat("\tARGUMENTS INFO\n")
23 args <- parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects 25 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') 26 write.table(as.matrix(args), col.names = F, quote = F, sep = "\t")
25 27
26 cat("\n\n") 28 cat("\n\n")
27 29
28 # ----- PROCESSING INFILE ----- 30 # ----- PROCESSING INFILE -----
29 cat("\tARGUMENTS PROCESSING INFO\n") 31 cat("\tARGUMENTS PROCESSING INFO\n")
48 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.*") 50 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.*")
49 51
50 # Handle infiles 52 # Handle infiles
51 if (!exists("singlefile")) singlefile <- NULL 53 if (!exists("singlefile")) singlefile <- NULL
52 if (!exists("zipfile")) zipfile <- NULL 54 if (!exists("zipfile")) zipfile <- NULL
53 rawFilePath <- retrieveRawfileInTheWorkingDirectory(singlefile, zipfile, args) 55 rawFilePath <- retrieveRawfileInTheWorkingDir(singlefile, zipfile, args)
54 zipfile <- rawFilePath$zipfile 56 zipfile <- rawFilePath$zipfile
55 singlefile <- rawFilePath$singlefile 57 singlefile <- rawFilePath$singlefile
56 58
57 cat("\n\n") 59 cat("\n\n")
58 60
63 65
64 cat("\t\tCOMPUTE\n") 66 cat("\t\tCOMPUTE\n")
65 67
66 68
67 cat("\t\t\tPerform the correspondence\n") 69 cat("\t\t\tPerform the correspondence\n")
68 args$sampleGroups = xdata$sample_group 70 args$sampleGroups <- xdata$sample_group
69 71
70 # clear the arguement list to remove unexpected key/value as singlefile_galaxyPath or method ... 72 # clear the arguement list to remove unexpected key/value as singlefile_galaxyPath or method ...
71 args <- args[names(args) %in% slotNames(do.call(paste0(method,"Param"), list(sampleGroups=c(1,2))))] 73 args <- args[names(args) %in% slotNames(do.call(paste0(method, "Param"), list(sampleGroups = c(1, 2))))]
72 74
73 groupChromPeaksParam <- do.call(paste0(method,"Param"), args) 75 groupChromPeaksParam <- do.call(paste0(method, "Param"), args)
74 print(groupChromPeaksParam) 76 print(groupChromPeaksParam)
75 xdata <- groupChromPeaks(xdata, param = groupChromPeaksParam) 77 xdata <- groupChromPeaks(xdata, param = groupChromPeaksParam)
76 78
77 79
78 cat("\t\tDRAW GRAPHICS\n") 80 cat("\t\tDRAW GRAPHICS\n")
95 xset <- getxcmsSetObject(xdata) 97 xset <- getxcmsSetObject(xdata)
96 print(xset) 98 print(xset)
97 cat("\n\n") 99 cat("\n\n")
98 100
99 #saving R data in .Rdata file to save the variables used in the present tool 101 #saving R data in .Rdata file to save the variables used in the present tool
100 objects2save = c("xdata","zipfile","singlefile","md5sumList","sampleNamesList") #, "chromTIC", "chromBPI", "chromTIC_adjusted", "chromBPI_adjusted") 102 objects2save <- c("xdata", "zipfile", "singlefile", "md5sumList", "sampleNamesList") #, "chromTIC", "chromBPI", "chromTIC_adjusted", "chromBPI_adjusted")
101 save(list=objects2save[objects2save %in% ls()], file="group.RData") 103 save(list = objects2save[objects2save %in% ls()], file = "group.RData")
102 104
103 cat("\n\n") 105 cat("\n\n")
104 106
105 107
106 cat("\tDONE\n") 108 cat("\tDONE\n")