Mercurial > repos > tomnl > mspurity_flagremove
annotate combineAnnotations.R @ 0:ca0ac330f1a4 draft
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
| author | tomnl |
|---|---|
| date | Fri, 24 May 2019 09:13:42 -0400 |
| parents | |
| children | 28fb8befb3b2 |
| rev | line source |
|---|---|
|
0
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
1 library(optparse) |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
2 library(msPurity) |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
3 print(sessionInfo()) |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
4 |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
5 # Get the parameter |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
6 option_list <- list( |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
7 make_option(c("-s","--sm_resultPth"),type="character"), |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
8 make_option(c("-m","--metfrag_resultPth"),type="character"), |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
9 make_option(c("-c","--sirius_csi_resultPth"),type="character"), |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
10 make_option(c("-p","--probmetab_resultPth"),type="character"), |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
11 make_option(c("-sw","--sm_weight"),type="numeric"), |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
12 make_option(c("-mw","--metfrag_weight"),type="numeric"), |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
13 make_option(c("-cw","--sirius_csi_weight"),type="numeric"), |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
14 make_option(c("-pw","--probmetab_weight"),type="numeric"), |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
15 make_option("--create_new_database", action="store_true"), |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
16 make_option(c("-o","--outdir"),type="character", default=".") |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
17 ) |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
18 opt <- parse_args(OptionParser(option_list=option_list)) |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
19 |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
20 print(opt) |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
21 |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
22 if (!is.null(opt$create_new_database)){ |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
23 sm_resultPth <- file.path(opt$outdir, 'combined_annotations.sqlite') |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
24 file.copy(opt$sm_resultPth, sm_resultPth) |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
25 }else{ |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
26 sm_resultPth <- opt$sm_resultPth |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
27 } |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
28 |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
29 |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
30 weights <-list('sm'=opt$sm_weight, |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
31 'metfrag'=opt$metfrag_weight, |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
32 'sirius_csifingerid'= opt$sirius_csi_weight, |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
33 'probmetab'=opt$probmetab_weight |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
34 ) |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
35 |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
36 if (round(!sum(unlist(weights),0)==1)){ |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
37 |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
38 stop(paste0('The weights should sum to 1 not ', sum(unlist(weights)))) |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
39 } |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
40 |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
41 summary_output <- msPurity::combineAnnotations(sm_resultPth, |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
42 opt$metfrag_resultPth, |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
43 opt$sirius_csi_resultPth, |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
44 opt$probmetab_resultPth, |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
45 weights = weights) |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
46 |
|
ca0ac330f1a4
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff
changeset
|
47 write.table(summary_output, file.path(opt$outdir, 'combined_annotations.tsv'), sep = '\t', row.names = FALSE) |
