SpectrumSimilarity: Similarity Between Two Mass Spectra

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/SpectrumSimilarity.R

Description

Generate a head-to-tail plot of the two mass spectra and calculate a similarity score.

Usage

1
2
3
SpectrumSimilarity(spec.top, spec.bottom, t = 0.25, b = 10, 
                   top.label = NULL, bottom.label = NULL, 
                   xlim = c(50, 1200))

Arguments

spec.top

data frame containing the experimental spectrum's peak list with the m/z values in the first column and corresponding intensities in the second

spec.bottom

data frame containing the reference spectrum's peak list with the m/z values in the first column and corresponding intensities in the second

t

numeric value specifying the tolerance used to align the m/z values of the two spectra.

b

numeric value specifying the baseline threshold for peak identification. Expressed as a percent of the maximum intensity.

top.label

character string to label the top spectrum.

bottom.label

character string to label the bottom spectrum.

xlim

numeric vector of length 2, defining the beginning and ending values of the x-axis.

Details

The mass spectral similarity score is calculated as (where %*% is the dot product)

cos θ = (u %*% v) / (sqrt(sum(u^2)) * sqrt(sum(v^2)))

where u and v are the aligned intensity vectors of the two spectra. The t argument is used to align the intensities. The bottom spectum is used as the reference spectrum, and the m/z values of peaks in the top spectrum that are within t of a reference m/z value are paired with that reference peak. Ideally, a single peak from the top spectrum should be paired with a single peak from the reference spectrum. Peaks without a match are paired with an intensity of zero. A data frame showing the aligned m/z values, peak intensities from the top spectrum, and peak intensities from the bottom spectrum, is printed in order to check the results. The unaligned spectra are shown in the plot.

Note that, although both are based on the cosine of the two intensity vectors, the spectral similarity score given by SpectrumSimilarity is not the same as that given by the NIST MS Search program, described in the reference below.

Value

A vector containing the similarity score. The data frame showing the peak alignment is printed. The head-to-tail plot of the two mass spectra is printed.

Author(s)

Nathan G. Dodder

References

"Optimization and Testing of Mass Spectral Library Search Algorithms for Compound Identification," Stein SE, Scott DR, Journal of the American Society for Mass Spectrometry, 1994, 5, 859-866.

See Also

PeptideSpectrum

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
SpectrumSimilarity(example.spectrum.unknown, example.spectrum.authentic,
                   top.label = "unknown, electron impact", 
                   bottom.label = "derivatized alanine, electron impact",
                   xlim = c(25, 350))
## label peaks
plot.window(xlim = c(25,350), ylim = c(-125, 125))
text(c(73, 147, 158, 232, 260), c(100, 23, 44, 22, 15) + 10,
     c(73, 147, 158, 232, 260), cex = 0.75)
text(c(73, 147, 158, 232, 260), -c(100, 47, 74, 33, 20) - 10, 
     c(73, 147, 158, 232, 260), cex = 0.75)
mtext("Spectrum similarity", line = 1)

Example output

    mz intensity.top intensity.bottom
1   45            10                0
2   59            17               17
3   73           100              100
4   74             0               10
5   75             0               11
6  147            23               47
7  158            44               74
8  159             0               12
9  232            22               33
10 260            15               20
[1] 0.9544485

OrgMassSpecR documentation built on May 31, 2017, 5 a.m.