From ad351294d63e113f96c974e27f332d882217bd7d Mon Sep 17 00:00:00 2001 From: yufree Date: Wed, 15 Jan 2025 09:41:44 -0500 Subject: [PATCH] remove pmdanno function to rmwf package --- DESCRIPTION | 5 ++-- NAMESPACE | 1 - NEWS.md | 1 + R/pmdanno.R | 77 -------------------------------------------------- man/pmdanno.Rd | 27 ------------------ 5 files changed, 3 insertions(+), 108 deletions(-) delete mode 100644 man/pmdanno.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 7d14b4c..ca80781 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -14,8 +14,7 @@ Encoding: UTF-8 LazyData: true Suggests: knitr, shiny, - rmarkdown, - MSnbase + rmarkdown VignetteBuilder: knitr biocViews: Depends: R (>= 3.5.0) @@ -26,4 +25,4 @@ Imports: RColorBrewer, data.table, igraph, enviGCMS -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 diff --git a/NAMESPACE b/NAMESPACE index f7f1b85..a65e469 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -24,6 +24,5 @@ export(plotsda) export(plotstd) export(plotstdrt) export(plotstdsda) -export(pmdanno) export(runPMD) export(runPMDnet) diff --git a/NEWS.md b/NEWS.md index 232324b..2a61ae6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,7 @@ - CRAN - Change URL to doi for citation +- remove dependance of msnbase # pmd 0.2.6 diff --git a/R/pmdanno.R b/R/pmdanno.R index bf863df..6bc9888 100644 --- a/R/pmdanno.R +++ b/R/pmdanno.R @@ -166,80 +166,3 @@ getmspmd <- function(file, digits = 2, icf = 10) { msmsraw = unname(msmsraw) )) } - -#' Perform MS/MS pmd annotation for mgf file -#' @param file mgf file generated from MS/MS data -#' @param db database could be list object from `getms2pmd` -#' @param ppm mass accuracy, default 10 -#' @param prems precursor mass range, default 1.1 to include M+H or M-H -#' @param pmdc pmd length percentage cutoff for annotation. 0.6(default) means 60 percentage of the pmds in your sample could be found in certain compound pmd database -#' @param scutoff relative intensity cutoff for input spectra for pmd analysis, default 0.1 -#' @return list with MSMS annotation results -#' @export -pmdanno <- function(file, - db = NULL, - ppm = 10, - prems = 1.1, - pmdc = 0.6, - scutoff = 0.1) { - namemgf <- basename(file) - sample <- MSnbase::readMgfData(file) - prec <- MSnbase::precursorMz(sample) - mz <- MSnbase::mz(sample) - ins <- MSnbase::intensity(sample) - idx <- unlist(ins) / max(unlist(ins)) > scutoff - if (sum(idx) > 0) { - mz <- unlist(mz)[idx] - ins <- unlist(ins)[idx] - ins <- ins / max(ins) * 100 - pmdt <- stats::dist(mz, method = "manhattan") - - if (is.list(db)) { - pmdt <- - unique(round(as.numeric(pmdt), digits = 2)) - range <- cbind(db$mz - prems, db$mz + prems) - mza <- data.table::as.data.table(cbind.data.frame(mzmin=db$mz - prems,mzmax= db$mz + prems)) - mzb <- data.table::as.data.table(cbind.data.frame(mzmin=prec - ppm / prec*1e-06,mzmax= prec + ppm / prec*1e-06)) - colnames(mza) <- colnames(mzb) <- c("min","max") - data.table::setkey(mzb, min, max) - overlapms <- data.table::foverlaps(mza, mzb, which = TRUE) - over <- overlapms[stats::complete.cases(overlapms)&!duplicated(overlapms),] - re <- data.frame(over) - if (nrow(re) > 0) { - msmsd <- db$msms[re$xid] - name <- db$name[re$xid] - mz2 <- db$mz[re$xid] - msmsraw <- db$msmsraw[re$xid] - - result <- vapply(msmsd, function(x) - sum(pmdt %in% unique(x)),1) - result <- c(result) - - if (sum(result > length(pmdt) * pmdc) == 0) { - return(NULL) - } else{ - re0 <- result[result > length(pmdt) * pmdc] - order <- order(re0,decreasing = TRUE) - t <- - list( - name = name[result > length(pmdt) * pmdc][order], - mz = mz2[result > length(pmdt) * pmdc][order], - msms = msmsd[result > length(pmdt) * pmdc][order], - msmsraw = msmsraw[result > length(pmdt) * pmdc][order], - dmz = mz, - dprc = prec, - dins = ins, - file = namemgf - ) - return(t) - } - } else{ - return(NULL) - } - } else{ - return(NULL) - } - } else{ - return(NULL) - } -} diff --git a/man/pmdanno.Rd b/man/pmdanno.Rd deleted file mode 100644 index 64c62ef..0000000 --- a/man/pmdanno.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pmdanno.R -\name{pmdanno} -\alias{pmdanno} -\title{Perform MS/MS pmd annotation for mgf file} -\usage{ -pmdanno(file, db = NULL, ppm = 10, prems = 1.1, pmdc = 0.6, scutoff = 0.1) -} -\arguments{ -\item{file}{mgf file generated from MS/MS data} - -\item{db}{database could be list object from `getms2pmd`} - -\item{ppm}{mass accuracy, default 10} - -\item{prems}{precursor mass range, default 1.1 to include M+H or M-H} - -\item{pmdc}{pmd length percentage cutoff for annotation. 0.6(default) means 60 percentage of the pmds in your sample could be found in certain compound pmd database} - -\item{scutoff}{relative intensity cutoff for input spectra for pmd analysis, default 0.1} -} -\value{ -list with MSMS annotation results -} -\description{ -Perform MS/MS pmd annotation for mgf file -}