Mercurial > repos > tomnl > mspurity_combineannotations
changeset 3:b22aa0a9fc25 draft
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
| author | tomnl |
|---|---|
| date | Tue, 18 Jun 2019 10:08:40 -0400 |
| parents | e912634293f5 |
| children | 68c405751ef6 |
| files | combineAnnotations.R combineAnnotations.xml createDatabase.R |
| diffstat | 3 files changed, 68 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- 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() +
--- 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 @@ -<tool id="mspurity_combineannotations" name="msPurity.combineAnnotations" version="0.2.1"> +<tool id="mspurity_combineannotations" name="msPurity.combineAnnotations" version="0.2.2"> <description> Combine, score and rank metabolite annotation results </description> @@ -26,16 +26,19 @@ #if $create_new_database: --create_new_database #end if + #if $eic + --eic + #end if ]]></command> <inputs> <param name="sm_resultPth" type="data" label="Spectral matching result" format="sqlite" help="The SQLite database generated from msPurity.spectralMatching"/> - <param name="metfrag_resultPth" type="data" label="Metfrag result" format="tsv,tabular" + <param name="metfrag_resultPth" type="data" label="Metfrag result" format="tsv,tabular" optional="true" help="The result of the MetFrag analysis (requires a column indicating the XCMS group ID and fragmentation spectra ID)"/> - <param name="sirius_csi_resultPth" type="data" label="Sirius CSI:FingerID result" format="tsv,tabular" + <param name="sirius_csi_resultPth" type="data" label="Sirius CSI:FingerID result" format="tsv,tabular" optional="true" help="The result of the CSI:FingerID analysis (requires a column indicating the XCMS group ID and fragmentation spectra ID)"/> - <param name="probmetab_resultPth" type="data" label="Probmetab result" format="tsv,tabular" + <param name="probmetab_resultPth" type="data" label="Probmetab result" format="tsv,tabular" optional="true" help="The result of the Probmetab analysis (requires a column indicating the XCMS group ID and fragmentation spectra ID)"/> <param name="sm_weight" type="float" min="0.0" max="1.0" value="0.4" label="Spectral matching weight" help="all weights need to sum to 1" /> <param name="metfrag_weight" type="float" min="0.0" max="1.0" value="0.25" label="Metfrag weight" help="all weights need to sum to 1" /> @@ -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."/> + <param name="eic" type="boolean" label="Include EIC data?" + help="The Extracted Ion Chromatogram can be calculated for each peak and stored in + the database. Note, this will take considerable time for large datasets and + the resulting SQLite database can be large"/> </inputs> <outputs> <data name="combined_annotations_sqlite" from_work_dir="combined_annotations.sqlite" format="sqlite" label="${tool.name} on ${on_string}: sqlite" />
--- 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()
