comparison CAMERA_annotateDiffreport.r @ 23:abf1775ac14d draft

"planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
author workflow4metabolomics
date Thu, 22 Apr 2021 10:27:38 +0000
parents 01459b73daf9
children 4b9ab71be05e
comparison
equal deleted inserted replaced
22:01bbba6d57ff 23:abf1775ac14d
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){ argv <- commandArgs(trailingOnly=FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) } 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 = "/"))
9 }
8 source_local("lib.r") 10 source_local("lib.r")
9 11
10 pkgs=c("CAMERA","multtest","batch") 12 pkgs <- c("CAMERA", "multtest", "batch")
11 loadAndDisplayPackages(pkgs) 13 loadAndDisplayPackages(pkgs)
12 cat("\n\n"); 14 cat("\n\n");
13 15
14 # ----- ARGUMENTS ----- 16 # ----- ARGUMENTS -----
15 cat("\tARGUMENTS INFO\n") 17 cat("\tARGUMENTS INFO\n")
16 18
17 args = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects 19 args <- parseCommandArgs(evaluate = FALSE) #interpretation of arguments given in command line as an R list of objects
18 write.table(as.matrix(args), col.names=F, quote=F, sep='\t') 20 write.table(as.matrix(args), col.names = F, quote = F, sep = "\t")
19 21
20 cat("\n\n"); 22 cat("\n\n");
21 23
22 24
23 # ----- PROCESSING INFILE ----- 25 # ----- PROCESSING INFILE -----
24 cat("\tINFILE PROCESSING INFO\n") 26 cat("\tINFILE PROCESSING INFO\n")
25 27
26 #image is an .RData file necessary to use xset variable given by previous tools 28 #image is an .RData file necessary to use xset variable given by previous tools
27 load(args$image); args$image=NULL 29 load(args$image); args$image <- NULL
28 30
29 cat("\n\n") 31 cat("\n\n")
30 32
31 33
32 # ----- ARGUMENTS PROCESSING ----- 34 # ----- ARGUMENTS PROCESSING -----
33 cat("\tARGUMENTS PROCESSING INFO\n") 35 cat("\tARGUMENTS PROCESSING INFO\n")
34 36
35 # Save arguments to generate a report 37 # Save arguments to generate a report
36 if (!exists("listOFargs")) listOFargs=list() 38 if (!exists("listOFargs")) listOFargs <- list()
37 listOFargs[[format(Sys.time(), "%y%m%d-%H:%M:%S_annotatediff")]] = args 39 listOFargs[[format(Sys.time(), "%y%m%d-%H:%M:%S_annotatediff")]] <- args
38 40
39 # We unzip automatically the chromatograms from the zip files. 41 # We unzip automatically the chromatograms from the zip files.
40 if (!exists("zipfile")) zipfile=NULL 42 if (!exists("zipfile")) zipfile <- NULL
41 if (!exists("singlefile")) singlefile=NULL 43 if (!exists("singlefile")) singlefile <- NULL
42 rawFilePath = getRawfilePathFromArguments(singlefile, zipfile, args) 44 rawFilePath <- getRawfilePathFromArguments(singlefile, zipfile, args)
43 zipfile = rawFilePath$zipfile 45 zipfile <- rawFilePath$zipfile
44 singlefile = rawFilePath$singlefile 46 singlefile <- rawFilePath$singlefile
45 args = rawFilePath$args 47 args <- rawFilePath$args
46 directory = retrieveRawfileInTheWorkingDirectory(singlefile, zipfile) 48 directory <- retrieveRawfileInTheWorkingDir(singlefile, zipfile)
47 49
48 50
49 # 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
50 if (exists("xdata")){ 52 if (exists("xdata")) {
51 xset <- getxcmsSetObject(xdata) 53 xset <- getxcmsSetObject(xdata)
52 } 54 }
53 55
54 cat("\n\n") 56 cat("\n\n")
55 57
56 58
57 # ----- PROCESSING INFO ----- 59 # ----- PROCESSING INFO -----
58 cat("\tMAIN PROCESSING INFO\n") 60 cat("\tMAIN PROCESSING INFO\n")
59 61
60 results_list=annotatediff(xset=xset,args=args,variableMetadataOutput="variableMetadata.tsv") 62 results_list <- annotatediff(xset = xset, args = args, variableMetadataOutput = "variableMetadata.tsv")
61 xa=results_list$xa 63 xa <- results_list$xa
62 diffrep=results_list$diffrep 64 diffrep <- results_list$diffrep
63 variableMetadata=results_list$variableMetadata 65 variableMetadata <- results_list$variableMetadata
64 66
65 cat("\n\n") 67 cat("\n\n")
66 68
67 # ----- EXPORT ----- 69 # ----- EXPORT -----
68 70
69 cat("\tXSET OBJECT INFO\n") 71 cat("\tXSET OBJECT INFO\n")
70 print(xa) 72 print(xa)
71 cat("\n\n") 73 cat("\n\n")
72 74
73 #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
74 objects2save = c("xa","variableMetadata","diffrep","cAnnot","listOFargs","zipfile","singlefile") 76 objects2save <- c("xa", "variableMetadata", "diffrep", "cAnnot", "listOFargs", "zipfile", "singlefile")
75 save(list=objects2save[objects2save %in% ls()], file="annotatediff.RData") 77 save(list = objects2save[objects2save %in% ls()], file = "annotatediff.RData")
76 78
77 cat("\n\n") 79 cat("\n\n")
78 80
79 cat("\tDONE\n") 81 cat("\tDONE\n")