Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

compareSpectra-methods

Compare Spectra of an 'MSnExp' or 'Spectrum' instances


Description

This method compares spectra (Spectrum instances) pairwise or all spectra of an experiment (MSnExp instances). Currently the comparison is based on the number of common peaks fun = "common", the Pearson correlation fun = "cor", the dot product fun = "dotproduct" or a user-defined function.

For fun = "common" the tolerance (default 25e-6) can be set and the tolerance can be defined to be relative (default relative = TRUE) or absolute (relative = FALSE). To compare spectra with fun = "cor" and fun = "dotproduct", the spectra need to be binned. The binSize argument (in Dalton) controls the binning precision. Please see bin for details.

Instead of these three predefined functions for fun a user-defined comparison function can be supplied. This function takes two Spectrum objects as the first two arguments and ... as third argument. The function must return a single numeric value. See the example section.

Methods

signature(object1 = "MSnExp", object2 = "missing", fun = "character", ...)

Compares all spectra in an MSnExp object. The ... arguments are passed to the internal functions. Returns a matrix of dimension length(object1) by length(object1).

signature(object1 = "Spectrum", object2 = "Spectrum", fun = "character", ...)

Compares two Spectrum objects. See the above explanation for fun and .... Returns a single numeric value.

Author(s)

Sebastian Gibb <mail@sebastiangibb.de>

References

Stein, S. E., & Scott, D. R. (1994). Optimization and testing of mass spectral library search algorithms for compound identification. Journal of the American Society for Mass Spectrometry, 5(9), 859-866. doi: https://doi.org/10.1016/1044-0305(94)87009-8

Lam, H., Deutsch, E. W., Eddes, J. S., Eng, J. K., King, N., Stein, S. E. and Aebersold, R. (2007) Development and validation of a spectral library searching method for peptide identification from MS/MS. Proteomics, 7: 655-667. doi: https://doi.org/10.1002/pmic.200600625

See Also

bin, clean, pickPeaks, smooth, removePeaks and trimMz for other spectra processing methods.

Examples

s1 <- new("Spectrum2", mz=1:10, intensity=1:10)
s2 <- new("Spectrum2", mz=1:10, intensity=10:1)
compareSpectra(s1, s2)
compareSpectra(s1, s2, fun="cor", binSize=2)
compareSpectra(s1, s2, fun="dotproduct")

## define our own (useless) comparison function (it is just a basic example)
equalLength <- function(x, y, ...) {
  return(peaksCount(x)/(peaksCount(y)+.Machine$double.eps))
}
compareSpectra(s1, s2, fun=equalLength)
compareSpectra(s1, new("Spectrum2", mz=1:5, intensity=1:5), fun=equalLength)
compareSpectra(s1, new("Spectrum2"), fun=equalLength)

data(itraqdata)
compareSpectra(itraqdata[1:5], fun="cor")

MSnbase

Base Functions and Classes for Mass Spectrometry and Proteomics

v2.16.1
Artistic-2.0
Authors
Laurent Gatto, Johannes Rainer and Sebastian Gibb with contributions from Guangchuang Yu, Samuel Wieczorek, Vasile-Cosmin Lazar, Vladislav Petyuk, Thomas Naake, Richie Cotton, Arne Smits, Martina Fisher, Ludger Goeminne, Adriaan Sticker and Lieven Clement.
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.