gnps | R Documentation |
The join_gnps
and gnps
functions allow to calculate spectra similarity
scores as used in GNPS. The approach matches first
peaks between the two spectra directly using a user-defined ppm and/or
tolerance as well as using a fixed delta m/z (considering the same ppm and
tolerance) that is defined by the difference of the two spectras' precursor
m/z values. For peaks that match multiple peaks in the
other spectrum only the matching peak pair with the higher value/similarity
is considered in the final similarity score calculation. Note that GNPS
similarity scores are calculated only if the two functions are used together.
join_gnps
: matches/maps peaks between spectra with the same approach
as in GNPS: peaks are considered matching if a) the
difference in their m/z values is smaller than defined by tolerance
and ppm
(this is the same as joinPeaks
) and b) the difference of
their m/z adjusted for the difference of the spectras' precursor is
smaller than defined by tolerance
and ppm
. Based on this definition,
peaks in x
can match up to two peaks in y
hence returned peak indices
might be duplicated. Note that if one of xPrecursorMz
or yPrecursorMz
are NA
or if both are the same, the results are the same as with
join()
. The function returns a list
of two integer
vectors with the
indices of the peaks matching peaks in the other spectrum or NA
otherwise.
gnps
: calculates the GNPS similarity score on peak matrices' previously
aligned (matched) with join_gnps
. For multi-mapping peaks the pair with
the higher similarity are considered in the final score calculation.
gnps(x, y, ...)
join_gnps(
x,
y,
xPrecursorMz = NA_real_,
yPrecursorMz = NA_real_,
tolerance = 0,
ppm = 0,
type = "outer",
...
)
x |
for |
y |
for |
... |
for |
xPrecursorMz |
for |
yPrecursorMz |
for |
tolerance |
for |
ppm |
for |
type |
for |
The implementation of gnps
bases on the R code from the publication listed
in the references.
See function definition in the description section.
Johannes Rainer, Michael Witting, based on the code from Xing et al. (2020).
Xing S, Hu Y, Yin Z, Liu M, Tang X, Fang M, Huan T. Retrieving and Utilizing Hypothetical Neutral Losses from Tandem Mass Spectra for Spectral Similarity Analysis and Unknown Metabolite Annotation. Anal Chem. 2020 Nov 3;92(21):14476-14483. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1021/acs.analchem.0c02521")}.
Other grouping/matching functions:
bin()
,
closest()
Other distance/similarity functions:
distance
## Define spectra
x <- cbind(mz = c(10, 36, 63, 91, 93), intensity = c(14, 15, 999, 650, 1))
y <- cbind(mz = c(10, 12, 50, 63, 105), intensity = c(35, 5, 16, 999, 450))
## The precursor m/z
pmz_x <- 91
pmz_y <- 105
## Plain join identifies only 2 matching peaks
join(x[, 1], y[, 1])
## join_gnps finds 4 matches
join_gnps(x[, 1], y[, 1], pmz_x, pmz_y)
## with one of the two precursor m/z being NA, the result are the same as
## with join.
join_gnps(x[, 1], y[, 1], pmz_x, yPrecursorMz = NA)
## Calculate GNPS similarity score:
map <- join_gnps(x[, 1], y[, 1], pmz_x, pmz_y)
gnps(x[map[[1]], ], y[map[[2]], ])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.