Mercurial > repos > computational-metabolomics > mspurity_purityx
diff filterFragSpectra.R @ 8:b16952cc06d2 draft
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
author | computational-metabolomics |
---|---|
date | Wed, 12 Jun 2024 16:02:20 +0000 |
parents | 942e676515fe |
children |
line wrap: on
line diff
--- a/filterFragSpectra.R Tue Feb 08 13:57:32 2022 +0000 +++ b/filterFragSpectra.R Wed Jun 12 16:02:20 2024 +0000 @@ -9,13 +9,10 @@ make_option("--out_peaklist_prec", type = "character"), make_option("--out_peaklist_frag", type = "character"), make_option("--pa", type = "character"), - make_option("--ilim", default = 0.0), make_option("--plim", default = 0.0), - make_option("--ra", default = 0.0), make_option("--snr", default = 0.0), - make_option("--rmp", action = "store_true"), make_option("--snmeth", default = "median", type = "character"), make_option("--allfrag", action = "store_true") @@ -26,9 +23,9 @@ loadRData <- function(rdata_path, name) { - #loads an RData file, and returns the named xset object if it is there - load(rdata_path) - return(get(ls()[ls() %in% name])) + # loads an RData file, and returns the named xset object if it is there + load(rdata_path) + return(get(ls()[ls() %in% name])) } # Requires @@ -36,24 +33,25 @@ if (is.null(opt$rmp)) { opt$rmp <- FALSE -}else{ +} else { opt$rmp <- TRUE } if (is.null(opt$allfrag)) { opt$allfrag <- FALSE -}else{ +} else { opt$allfrag <- TRUE } pa <- filterFragSpectra(pa, - ilim = opt$ilim, - plim = opt$plim, - ra = opt$ra, - snr = opt$snr, - rmp = opt$rmp, - allfrag = opt$allfrag, - snmeth = opt$snmeth) + ilim = opt$ilim, + plim = opt$plim, + ra = opt$ra, + snr = opt$snr, + rmp = opt$rmp, + allfrag = opt$allfrag, + snmeth = opt$snmeth +) print(pa) save(pa, file = opt$out_rdata) @@ -82,11 +80,9 @@ if (length(pa) > 0) { - if (length(pa@grped_ms2) == 0) { message("No spectra available") } else { - # get group ids grpids <- unique(as.character(pa@grped_df$grpid)) @@ -94,7 +90,7 @@ df_fragments <- plyr::adply(grpids, 1, msmsgrp, pa = pa) df_fragments <- merge(df_fragments, pa@puritydf[, c("pid", "acquisitionNum", "precursorScanNum")], by = "pid") df_fragments <- df_fragments[order(df_fragments$grpid, df_fragments$pid, df_fragments$mz), ] - #select and reorder columns + # select and reorder columns df_fragments <- df_fragments[, c("grpid", "pid", "precursorScanNum", "acquisitionNum", "fileid", "mz", "i", "snr", "ra", "purity_pass_flag", "intensity_pass_flag", "ra_pass_flag", "snr_pass_flag", "pass_flag")] pa@grped_df$filename <- sapply(pa@grped_df$fileid, function(x) names(pa@fileList)[as.integer(x)])