annotate CAMERA_annotateDiffreport.r @ 21:3886548ea1d1 draft

"planemo upload commit f978cc0a7aa81c244591e560f44970f0d61bf74e"
author workflow4metabolomics
date Sat, 28 Mar 2020 10:40:31 -0400
parents 01459b73daf9
children abf1775ac14d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
1 #!/usr/bin/env Rscript
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
2
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
3 # ----- PACKAGE -----
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
4 cat("\tSESSION INFO\n")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
5
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
6 #Import the different functions
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
7 source_local <- function(fname){ argv <- commandArgs(trailingOnly=FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) }
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
8 source_local("lib.r")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
9
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
10 pkgs=c("CAMERA","multtest","batch")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
11 loadAndDisplayPackages(pkgs)
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
12 cat("\n\n");
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
13
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
14 # ----- ARGUMENTS -----
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
15 cat("\tARGUMENTS INFO\n")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
16
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
17 args = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
18 write.table(as.matrix(args), col.names=F, quote=F, sep='\t')
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
19
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
20 cat("\n\n");
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
21
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
22
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
23 # ----- PROCESSING INFILE -----
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
24 cat("\tINFILE PROCESSING INFO\n")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
25
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
26 #image is an .RData file necessary to use xset variable given by previous tools
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
27 load(args$image); args$image=NULL
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
28
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
29 cat("\n\n")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
30
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
31
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
32 # ----- ARGUMENTS PROCESSING -----
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
33 cat("\tARGUMENTS PROCESSING INFO\n")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
34
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
35 # Save arguments to generate a report
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
36 if (!exists("listOFargs")) listOFargs=list()
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
37 listOFargs[[format(Sys.time(), "%y%m%d-%H:%M:%S_annotatediff")]] = args
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
38
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
39 # We unzip automatically the chromatograms from the zip files.
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
40 if (!exists("zipfile")) zipfile=NULL
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
41 if (!exists("singlefile")) singlefile=NULL
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
42 rawFilePath = getRawfilePathFromArguments(singlefile, zipfile, args)
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
43 zipfile = rawFilePath$zipfile
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
44 singlefile = rawFilePath$singlefile
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
45 args = rawFilePath$args
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
46 directory = retrieveRawfileInTheWorkingDirectory(singlefile, zipfile)
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
47
19
01459b73daf9 "planemo upload commit 4fcbbcbc6d6b0a59e801870d31fe886a920ef429"
workflow4metabolomics
parents: 18
diff changeset
48
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
49 # Because so far CAMERA isn't compatible with the new XCMSnExp object
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
50 if (exists("xdata")){
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
51 xset <- getxcmsSetObject(xdata)
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
52 }
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
53
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
54 cat("\n\n")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
55
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
56
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
57 # ----- PROCESSING INFO -----
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
58 cat("\tMAIN PROCESSING INFO\n")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
59
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
60 results_list=annotatediff(xset=xset,args=args,variableMetadataOutput="variableMetadata.tsv")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
61 xa=results_list$xa
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
62 diffrep=results_list$diffrep
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
63 variableMetadata=results_list$variableMetadata
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
64
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
65 cat("\n\n")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
66
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
67 # ----- EXPORT -----
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
68
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
69 cat("\tXSET OBJECT INFO\n")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
70 print(xa)
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
71 cat("\n\n")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
72
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
73 #saving R data in .Rdata file to save the variables used in the present tool
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
74 objects2save = c("xa","variableMetadata","diffrep","cAnnot","listOFargs","zipfile","singlefile")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
75 save(list=objects2save[objects2save %in% ls()], file="annotatediff.RData")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
76
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
77 cat("\n\n")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
78
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff changeset
79 cat("\tDONE\n")