Mercurial > repos > tomnl > mspurity_flagremove
changeset 4:28fb8befb3b2 draft
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
| author | tomnl |
|---|---|
| date | Tue, 18 Jun 2019 09:50:03 -0400 |
| parents | 59c1f9077c3b |
| children | 1a77ed3c94b7 |
| files | combineAnnotations.R createDatabase.R |
| diffstat | 2 files changed, 57 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/combineAnnotations.R Fri Jun 14 08:55:15 2019 -0400 +++ b/combineAnnotations.R Tue Jun 18 09:50:03 2019 -0400 @@ -13,7 +13,8 @@ make_option(c("-cw","--sirius_csi_weight"),type="numeric"), make_option(c("-pw","--probmetab_weight"),type="numeric"), make_option("--create_new_database", action="store_true"), - make_option(c("-o","--outdir"),type="character", default=".") + make_option(c("-o","--outdir"),type="character", default="."), + make_option("--eic", action="store_true") ) opt <- parse_args(OptionParser(option_list=option_list)) @@ -45,3 +46,33 @@ weights = weights) write.table(summary_output, file.path(opt$outdir, 'combined_annotations.tsv'), sep = '\t', row.names = FALSE) + +if (!is.null(opt$eic)){ + + if (is.null(xset)){ + xset <- xa@xcmsSet + } + # previous check should have matched filelists together + xset@filepaths <- unname(pa@fileList) + + convert2Raw <- function(x, xset){ + sid <- unique(x$sample) + # for each file get list of peaks + x$rt_raw <- xset@rt$raw[[sid]][match(x$rt, xset@rt$corrected[[sid]])] + x$rtmin_raw <- xset@rt$raw[[sid]][match(x$rtmin, xset@rt$corrected[[sid]])] + x$rtmax_raw <- xset@rt$raw[[sid]][match(x$rtmax, xset@rt$corrected[[sid]])] + return(x) + + } + + xset@peaks <- as.matrix(plyr::ddply(data.frame(xset@peaks), ~ sample, convert2Raw, xset=xset)) + + # Saves the EICS into the previously created database + px <- msPurity::purityX(xset, saveEIC = TRUE, + cores=1, sqlitePth=db_pth, + rtrawColumns = TRUE) + +} + +closeAllConnections() +
--- a/createDatabase.R Fri Jun 14 08:55:15 2019 -0400 +++ b/createDatabase.R Tue Jun 18 09:50:03 2019 -0400 @@ -10,7 +10,7 @@ xset_pa_filename_fix <- function(opt, pa, xset){ if (!is.null(opt$mzML_files) && !is.null(opt$galaxy_names)){ - # NOTE: Relies on the pa@fileList having the names of files given as 'names' of the variables + # NOTE: Relies on the pa@fileList having the names of files given as 'names' of the variables # needs to be done due to Galaxy moving the files around and screwing up any links to files filepaths <- trimws(strsplit(opt$mzML_files, ',')[[1]]) @@ -58,8 +58,7 @@ make_option("--cores", default=4), make_option("--mzML_files", type="character"), make_option("--galaxy_names", type="character"), - make_option("--grpPeaklist", type="character"), - make_option("--raw_rt_columns", action="store_true") + make_option("--grpPeaklist", type="character") ) @@ -100,17 +99,17 @@ if (opt$xcms_camera_option=='xcms'){ - + xset <- loadRData(opt$xset, c('xset','xdata')) xset <- getxcmsSetObject(xset) - fix <- xset_pa_filename_fix(opt, pa, xset) + fix <- xset_pa_filename_fix(opt, pa, xset) pa <- fix[[1]] xset <- fix[[2]] xa <- NULL }else{ - + xa <- loadRData(opt$xset, 'xa') - fix <- xset_pa_filename_fix(opt, pa, xa@xcmsSet) + fix <- xset_pa_filename_fix(opt, pa, xa@xcmsSet) pa <- fix[[1]] xa@xcmsSet <- fix[[2]] xset <- NULL @@ -128,7 +127,7 @@ dbPth <- msPurity::createDatabase(pa, xset=xset, - xsa=xa, + xsa=xa, outDir=opt$outDir, grpPeaklist=grpPeaklist, dbName='createDatabase_output.sqlite' @@ -136,22 +135,33 @@ + + if (!is.null(opt$eic)){ - if (is.null(opt$raw_rt_columns)){ - rtrawColumns <- FALSE - }else{ - rtrawColumns <- TRUE - } + if (is.null(xset)){ xset <- xa@xcmsSet } # previous check should have matched filelists together xset@filepaths <- unname(pa@fileList) + convert2Raw <- function(x, xset){ + sid <- unique(x$sample) + # for each file get list of peaks + x$rt_raw <- xset@rt$raw[[sid]][match(x$rt, xset@rt$corrected[[sid]])] + x$rtmin_raw <- xset@rt$raw[[sid]][match(x$rtmin, xset@rt$corrected[[sid]])] + x$rtmax_raw <- xset@rt$raw[[sid]][match(x$rtmax, xset@rt$corrected[[sid]])] + return(x) + + } + + xset@peaks <- as.matrix(plyr::ddply(data.frame(xset@peaks), ~ sample, convert2Raw, xset=xset)) + # Saves the EICS into the previously created database px <- msPurity::purityX(xset, saveEIC = TRUE, cores=1, sqlitePth=db_pth, - rtrawColumns = rtrawColumns) + rtrawColumns = TRUE) + } -con <- DBI::dbConnect(RSQLite::SQLite(), dbPth) +closeAllConnections()
