Mercurial > repos > lecorguille > camera_annotate
annotate CAMERA_annotateDiffreport.r @ 18:cb923396e70f draft
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
author | lecorguille |
---|---|
date | Thu, 29 Aug 2019 11:38:21 -0400 |
parents | |
children | 01459b73daf9 |
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 |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
48 # Because so far CAMERA isn't compatible with the new XCMSnExp object |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
49 if (exists("xdata")){ |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
50 xset <- getxcmsSetObject(xdata) |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
51 } |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
52 |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
53 cat("\n\n") |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
54 |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
55 |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
56 # ----- PROCESSING INFO ----- |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
57 cat("\tMAIN PROCESSING INFO\n") |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
58 |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
59 results_list=annotatediff(xset=xset,args=args,variableMetadataOutput="variableMetadata.tsv") |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
60 xa=results_list$xa |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
61 diffrep=results_list$diffrep |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
62 variableMetadata=results_list$variableMetadata |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
63 |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
64 cat("\n\n") |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
65 |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
66 # ----- EXPORT ----- |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
67 |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
68 cat("\tXSET OBJECT INFO\n") |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
69 print(xa) |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
70 cat("\n\n") |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
71 |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
72 #saving R data in .Rdata file to save the variables used in the present tool |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
73 objects2save = c("xa","variableMetadata","diffrep","cAnnot","listOFargs","zipfile","singlefile") |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
74 save(list=objects2save[objects2save %in% ls()], file="annotatediff.RData") |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
75 |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
76 cat("\n\n") |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
77 |
cb923396e70f
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents:
diff
changeset
|
78 cat("\tDONE\n") |