Mercurial > repos > computational-metabolomics > mspurity_purityx
diff averageFragSpectra.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 | 6b9a83e08467 |
children |
line wrap: on
line diff
--- a/averageFragSpectra.R Tue Feb 08 13:57:32 2022 +0000 +++ b/averageFragSpectra.R Wed Jun 12 16:02:20 2024 +0000 @@ -5,30 +5,28 @@ get_av_spectra <- function(x) { - if (length(x$av_intra) > 0) { av_intra_df <- plyr::ldply(x$av_intra) if (nrow(av_intra_df) == 0) { av_intra_df <- NULL - }else{ + } else { av_intra_df$method <- "intra" } - - }else{ + } else { av_intra_df <- NULL } if ((is.null(x$av_inter)) || (nrow(x$av_inter) == 0)) { av_inter_df <- NULL - }else{ + } else { av_inter_df <- x$av_inter av_inter_df$method <- "inter" } if ((is.null(x$av_all)) || (nrow(x$av_all) == 0)) { av_all_df <- NULL - }else{ + } else { av_all_df <- x$av_all av_all_df$method <- "all" } @@ -60,9 +58,9 @@ load_r_data <- 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 @@ -72,59 +70,58 @@ if (is.null(opt$rmp)) { rmp <- FALSE -}else{ +} else { rmp <- TRUE } if (is.null(opt$sumi)) { sumi <- FALSE -}else{ +} else { sumi <- TRUE } if (opt$av_level == "intra") { pa <- msPurity::averageIntraFragSpectra(pa, - minfrac = opt$minfrac, - minnum = opt$minnum, - ppm = opt$ppm, - snr = opt$snr, - ra = opt$ra, - av = opt$av, - sumi = sumi, - rmp = rmp, - cores = opt$cores) - + minfrac = opt$minfrac, + minnum = opt$minnum, + ppm = opt$ppm, + snr = opt$snr, + ra = opt$ra, + av = opt$av, + sumi = sumi, + rmp = rmp, + cores = opt$cores + ) } else if (opt$av_level == "inter") { - pa <- msPurity::averageInterFragSpectra(pa, - minfrac = opt$minfrac, - minnum = opt$minnum, - ppm = opt$ppm, - snr = opt$snr, - ra = opt$ra, - av = opt$av, - sumi = sumi, - rmp = rmp, - cores = opt$cores) + minfrac = opt$minfrac, + minnum = opt$minnum, + ppm = opt$ppm, + snr = opt$snr, + ra = opt$ra, + av = opt$av, + sumi = sumi, + rmp = rmp, + cores = opt$cores + ) } else if (opt$av_level == "all") { - pa <- msPurity::averageAllFragSpectra(pa, - minfrac = opt$minfrac, - minnum = opt$minnum, - ppm = opt$ppm, - snr = opt$snr, - ra = opt$ra, - av = opt$av, - sumi = sumi, - rmp = rmp, - cores = opt$cores) + minfrac = opt$minfrac, + minnum = opt$minnum, + ppm = opt$ppm, + snr = opt$snr, + ra = opt$ra, + av = opt$av, + sumi = sumi, + rmp = rmp, + cores = opt$cores + ) } print(pa) save(pa, file = opt$out_rdata) if (length(pa) > 0) { - av_spectra <- plyr::ldply(pa@av_spectra, get_av_spectra) if (nrow(av_spectra) == 0) { @@ -138,18 +135,20 @@ colnames(av_spectra)[2] <- "fileid" av_spectra$avid <- seq_len(nrow(av_spectra)) - filenames <- sapply(av_spectra$fileid, - function(x) names(pa@fileList)[as.integer(x)]) + filenames <- sapply( + av_spectra$fileid, + function(x) names(pa@fileList)[as.integer(x)] + ) # filenames_galaxy <- sapply( # av_spectra$fileid, function(x) basename(pa@fileList[as.integer(x)])) - av_spectra <- as.data.frame( - append(av_spectra, list(filename = filenames), after = 2)) + av_spectra <- as.data.frame( + append(av_spectra, list(filename = filenames), after = 2) + ) } print(head(av_spectra)) write.table(av_spectra, opt$out_peaklist, row.names = FALSE, sep = "\t") - } }