comparison CAMERA_annotateDiffreport.r @ 25:4b9ab71be05e draft

planemo upload commit cfad09eb4dd6b1439b7de6a0852cd8fa22210f58
author workflow4metabolomics
date Mon, 11 Sep 2023 22:40:34 +0000
parents abf1775ac14d
children 3d63a762954a
comparison
equal deleted inserted replaced
24:512c2b701d96 25:4b9ab71be05e
1 #!/usr/bin/env Rscript 1 #!/usr/bin/env Rscript
2 2
3 # ----- PACKAGE ----- 3 # ----- PACKAGE -----
4 cat("\tSESSION INFO\n") 4 cat("\tSESSION INFO\n")
5 5
6 #Import the different functions 6 # Import the different functions
7 source_local <- function(fname) { 7 source_local <- function(fname) {
8 argv <- commandArgs(trailingOnly = FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep = "/")) 8 argv <- commandArgs(trailingOnly = FALSE)
9 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
10 source(paste(base_dir, fname, sep = "/"))
9 } 11 }
10 source_local("lib.r") 12 source_local("lib.r")
11 13
12 pkgs <- c("CAMERA", "multtest", "batch") 14 pkgs <- c("CAMERA", "multtest", "batch")
13 loadAndDisplayPackages(pkgs) 15 loadAndDisplayPackages(pkgs)
14 cat("\n\n"); 16 cat("\n\n")
15
16 # ----- ARGUMENTS ----- 17 # ----- ARGUMENTS -----
17 cat("\tARGUMENTS INFO\n") 18 cat("\tARGUMENTS INFO\n")
18 19
19 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
20 write.table(as.matrix(args), col.names = F, quote = F, sep = "\t") 21 write.table(as.matrix(args), col.names = FALSE, quote = FALSE, sep = "\t")
21 22
22 cat("\n\n"); 23 cat("\n\n")
23
24
25 # ----- PROCESSING INFILE ----- 24 # ----- PROCESSING INFILE -----
26 cat("\tINFILE PROCESSING INFO\n") 25 cat("\tINFILE PROCESSING INFO\n")
27 26
28 #image is an .RData file necessary to use xset variable given by previous tools 27 # image is an .RData file necessary to use xset variable given by previous tools
29 load(args$image); args$image <- NULL 28 load(args$image)
29 args$image <- NULL
30 30
31 cat("\n\n") 31 cat("\n\n")
32 32
33 33
34 # ----- ARGUMENTS PROCESSING ----- 34 # ----- ARGUMENTS PROCESSING -----
48 directory <- retrieveRawfileInTheWorkingDir(singlefile, zipfile) 48 directory <- retrieveRawfileInTheWorkingDir(singlefile, zipfile)
49 49
50 50
51 # Because so far CAMERA isn't compatible with the new XCMSnExp object 51 # Because so far CAMERA isn't compatible with the new XCMSnExp object
52 if (exists("xdata")) { 52 if (exists("xdata")) {
53 xset <- getxcmsSetObject(xdata) 53 xset <- getxcmsSetObject(xdata)
54 } 54 }
55 55
56 cat("\n\n") 56 cat("\n\n")
57 57
58 58
70 70
71 cat("\tXSET OBJECT INFO\n") 71 cat("\tXSET OBJECT INFO\n")
72 print(xa) 72 print(xa)
73 cat("\n\n") 73 cat("\n\n")
74 74
75 #saving R data in .Rdata file to save the variables used in the present tool 75 # saving R data in .Rdata file to save the variables used in the present tool
76 objects2save <- c("xa", "variableMetadata", "diffrep", "cAnnot", "listOFargs", "zipfile", "singlefile") 76 objects2save <- c("xa", "variableMetadata", "diffrep", "cAnnot", "listOFargs", "zipfile", "singlefile")
77 save(list = objects2save[objects2save %in% ls()], file = "annotatediff.RData") 77 save(list = objects2save[objects2save %in% ls()], file = "annotatediff.RData")
78 78
79 cat("\n\n") 79 cat("\n\n")
80 80