annotate CAMERA_combinexsAnnos.r @ 2:c4c13745e797 draft

"planemo upload commit f978cc0a7aa81c244591e560f44970f0d61bf74e"
author workflow4metabolomics
date Sat, 28 Mar 2020 10:41:07 -0400
parents 139ff66b0b5d
children 4c4945bce185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
1 #!/usr/bin/env Rscript
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
2
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
3 # ----- PACKAGE -----
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
4 cat("\tSESSION INFO\n")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
5
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
6 #Import the different functions
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
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="/")) }
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
8 source_local("lib.r")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
9
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
10 pkgs=c("CAMERA","multtest","batch")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
11 loadAndDisplayPackages(pkgs)
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
12 cat("\n\n");
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
13
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
14 # ----- ARGUMENTS -----
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
15 cat("\tARGUMENTS INFO\n")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
16
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
17 args = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
18 write.table(as.matrix(args), col.names=F, quote=F, sep='\t')
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
19
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
20 cat("\n\n");
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
21
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
22
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
23 # ----- PROCESSING INFILE -----
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
24 cat("\tINFILE PROCESSING INFO\n")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
25
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
26 #image is an .RData file necessary to use xset variable given by previous tools
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
27 load(args$image_pos)
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
28 xaP=xa
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
29
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
30 diffrepP=NULL
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
31 if (exists("diffrep")) diffrepP=diffrep
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
32
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
33 load(args$image_neg)
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
34 xaN=xa
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
35
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
36 diffrepN=NULL
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
37 if (exists("diffrep")) diffrepN=diffrep
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
38
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
39
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
40 cat("\n\n")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
41
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
42
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
43 # ----- ARGUMENTS PROCESSING -----
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
44 cat("\tARGUMENTS PROCESSING INFO\n")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
45
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
46 # Save arguments to generate a report
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
47 if (!exists("listOFargs")) listOFargs=list()
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
48 listOFargs[[format(Sys.time(), "%y%m%d-%H:%M:%S_combinexsAnnos")]] = args
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
49
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
50 cat("\n\n")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
51
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
52
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
53 # ----- PROCESSING INFO -----
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
54 cat("\tMAIN PROCESSING INFO\n")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
55
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
56 cAnnot=combinexsAnnos_function(
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
57 xaP=xaP,xaN=xaN,
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
58 diffrepP=diffrepP, diffrepN=diffrepN,
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
59 pos=args$pos, tol=args$tol,ruleset=args$ruleset, keep_meta=args$keep_meta,
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
60 convertRTMinute=args$convertRTMinute, numDigitsMZ=args$numDigitsMZ, numDigitsRT=args$numDigitsRT,
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
61 variableMetadataOutput="variableMetadata.tsv"
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
62 )
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
63
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
64 # ----- EXPORT -----
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
65
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
66 #saving R data in .Rdata file to save the variables used in the present tool
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
67 objects2save = c("xa","variableMetadata","diffrep","cAnnot","listOFargs","zipfile","singlefile")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
68 save(list=objects2save[objects2save %in% ls()], file="combinexsAnnos.RData")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
69
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
70 cat("\n\n")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
71
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
72 cat("\tDONE\n")