Mercurial > repos > tomnl > mspurity_flagremove
comparison 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 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:ca0ac330f1a4 |
|---|---|
| 1 library(optparse) | |
| 2 library(msPurity) | |
| 3 print(sessionInfo()) | |
| 4 | |
| 5 # Get the parameter | |
| 6 option_list <- list( | |
| 7 make_option(c("-s","--sm_resultPth"),type="character"), | |
| 8 make_option(c("-m","--metfrag_resultPth"),type="character"), | |
| 9 make_option(c("-c","--sirius_csi_resultPth"),type="character"), | |
| 10 make_option(c("-p","--probmetab_resultPth"),type="character"), | |
| 11 make_option(c("-sw","--sm_weight"),type="numeric"), | |
| 12 make_option(c("-mw","--metfrag_weight"),type="numeric"), | |
| 13 make_option(c("-cw","--sirius_csi_weight"),type="numeric"), | |
| 14 make_option(c("-pw","--probmetab_weight"),type="numeric"), | |
| 15 make_option("--create_new_database", action="store_true"), | |
| 16 make_option(c("-o","--outdir"),type="character", default=".") | |
| 17 ) | |
| 18 opt <- parse_args(OptionParser(option_list=option_list)) | |
| 19 | |
| 20 print(opt) | |
| 21 | |
| 22 if (!is.null(opt$create_new_database)){ | |
| 23 sm_resultPth <- file.path(opt$outdir, 'combined_annotations.sqlite') | |
| 24 file.copy(opt$sm_resultPth, sm_resultPth) | |
| 25 }else{ | |
| 26 sm_resultPth <- opt$sm_resultPth | |
| 27 } | |
| 28 | |
| 29 | |
| 30 weights <-list('sm'=opt$sm_weight, | |
| 31 'metfrag'=opt$metfrag_weight, | |
| 32 'sirius_csifingerid'= opt$sirius_csi_weight, | |
| 33 'probmetab'=opt$probmetab_weight | |
| 34 ) | |
| 35 | |
| 36 if (round(!sum(unlist(weights),0)==1)){ | |
| 37 | |
| 38 stop(paste0('The weights should sum to 1 not ', sum(unlist(weights)))) | |
| 39 } | |
| 40 | |
| 41 summary_output <- msPurity::combineAnnotations(sm_resultPth, | |
| 42 opt$metfrag_resultPth, | |
| 43 opt$sirius_csi_resultPth, | |
| 44 opt$probmetab_resultPth, | |
| 45 weights = weights) | |
| 46 | |
| 47 write.table(summary_output, file.path(opt$outdir, 'combined_annotations.tsv'), sep = '\t', row.names = FALSE) |
