# HG changeset patch # User tomnl # Date 1560866920 14400 # Node ID b22aa0a9fc256f6eff45c87f78311cc0e8c088b1 # Parent e912634293f5021cd545e5c1249f0c373ac8d993 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty diff -r e912634293f5 -r b22aa0a9fc25 combineAnnotations.R --- a/combineAnnotations.R Fri Jun 14 09:10:43 2019 -0400 +++ b/combineAnnotations.R Tue Jun 18 10:08:40 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() + diff -r e912634293f5 -r b22aa0a9fc25 combineAnnotations.xml --- a/combineAnnotations.xml Fri Jun 14 09:10:43 2019 -0400 +++ b/combineAnnotations.xml Tue Jun 18 10:08:40 2019 -0400 @@ -1,4 +1,4 @@ - + Combine, score and rank metabolite annotation results @@ -26,16 +26,19 @@ #if $create_new_database: --create_new_database #end if + #if $eic + --eic + #end if ]]> - - - @@ -45,6 +48,10 @@ help="A copy will be made of the input SQLite spectral matching database and the results will be added to this copy. When False, the input SQLite database will be updated the results. Use False if you want to reduce storage space being used."/> + diff -r e912634293f5 -r b22aa0a9fc25 createDatabase.R --- a/createDatabase.R Fri Jun 14 09:10:43 2019 -0400 +++ b/createDatabase.R Tue Jun 18 10:08:40 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()