Mercurial > repos > tomnl > mspurity_createmsp
comparison combineAnnotations.R @ 4:13985cdcf0ba draft
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
| author | tomnl |
|---|---|
| date | Tue, 18 Jun 2019 09:56:18 -0400 |
| parents | df2efceff4cd |
| children | 3de08f3c4fb6 |
comparison
equal
deleted
inserted
replaced
| 3:5dd59c833c34 | 4:13985cdcf0ba |
|---|---|
| 11 make_option(c("-sw","--sm_weight"),type="numeric"), | 11 make_option(c("-sw","--sm_weight"),type="numeric"), |
| 12 make_option(c("-mw","--metfrag_weight"),type="numeric"), | 12 make_option(c("-mw","--metfrag_weight"),type="numeric"), |
| 13 make_option(c("-cw","--sirius_csi_weight"),type="numeric"), | 13 make_option(c("-cw","--sirius_csi_weight"),type="numeric"), |
| 14 make_option(c("-pw","--probmetab_weight"),type="numeric"), | 14 make_option(c("-pw","--probmetab_weight"),type="numeric"), |
| 15 make_option("--create_new_database", action="store_true"), | 15 make_option("--create_new_database", action="store_true"), |
| 16 make_option(c("-o","--outdir"),type="character", default=".") | 16 make_option(c("-o","--outdir"),type="character", default="."), |
| 17 make_option("--eic", action="store_true") | |
| 17 ) | 18 ) |
| 18 opt <- parse_args(OptionParser(option_list=option_list)) | 19 opt <- parse_args(OptionParser(option_list=option_list)) |
| 19 | 20 |
| 20 print(opt) | 21 print(opt) |
| 21 | 22 |
| 43 opt$sirius_csi_resultPth, | 44 opt$sirius_csi_resultPth, |
| 44 opt$probmetab_resultPth, | 45 opt$probmetab_resultPth, |
| 45 weights = weights) | 46 weights = weights) |
| 46 | 47 |
| 47 write.table(summary_output, file.path(opt$outdir, 'combined_annotations.tsv'), sep = '\t', row.names = FALSE) | 48 write.table(summary_output, file.path(opt$outdir, 'combined_annotations.tsv'), sep = '\t', row.names = FALSE) |
| 49 | |
| 50 if (!is.null(opt$eic)){ | |
| 51 | |
| 52 if (is.null(xset)){ | |
| 53 xset <- xa@xcmsSet | |
| 54 } | |
| 55 # previous check should have matched filelists together | |
| 56 xset@filepaths <- unname(pa@fileList) | |
| 57 | |
| 58 convert2Raw <- function(x, xset){ | |
| 59 sid <- unique(x$sample) | |
| 60 # for each file get list of peaks | |
| 61 x$rt_raw <- xset@rt$raw[[sid]][match(x$rt, xset@rt$corrected[[sid]])] | |
| 62 x$rtmin_raw <- xset@rt$raw[[sid]][match(x$rtmin, xset@rt$corrected[[sid]])] | |
| 63 x$rtmax_raw <- xset@rt$raw[[sid]][match(x$rtmax, xset@rt$corrected[[sid]])] | |
| 64 return(x) | |
| 65 | |
| 66 } | |
| 67 | |
| 68 xset@peaks <- as.matrix(plyr::ddply(data.frame(xset@peaks), ~ sample, convert2Raw, xset=xset)) | |
| 69 | |
| 70 # Saves the EICS into the previously created database | |
| 71 px <- msPurity::purityX(xset, saveEIC = TRUE, | |
| 72 cores=1, sqlitePth=db_pth, | |
| 73 rtrawColumns = TRUE) | |
| 74 | |
| 75 } | |
| 76 | |
| 77 closeAllConnections() | |
| 78 |
