Skip to content

Commit

Permalink
remove pmdanno function to rmwf package
Browse files Browse the repository at this point in the history
  • Loading branch information
yufree committed Jan 15, 2025
1 parent 1d95f5c commit ad35129
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 108 deletions.
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ Encoding: UTF-8
LazyData: true
Suggests: knitr,
shiny,
rmarkdown,
MSnbase
rmarkdown
VignetteBuilder: knitr
biocViews:
Depends: R (>= 3.5.0)
Expand All @@ -26,4 +25,4 @@ Imports: RColorBrewer,
data.table,
igraph,
enviGCMS
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ export(plotsda)
export(plotstd)
export(plotstdrt)
export(plotstdsda)
export(pmdanno)
export(runPMD)
export(runPMDnet)
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- CRAN
- Change URL to doi for citation
- remove dependance of msnbase

# pmd 0.2.6

Expand Down
77 changes: 0 additions & 77 deletions R/pmdanno.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
27 changes: 0 additions & 27 deletions man/pmdanno.Rd

This file was deleted.

0 comments on commit ad35129

Please sign in to comment.