| compareSpectra-methods {MSnbase} | R Documentation |
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.
signature(x = "MSnExp", y = "missing", fun =
"character", ...)Compares all spectra in an MSnExp
object. The ... arguments are passed to the internal
functions. Returns a matrix of dimension
length(x) by length(x).
signature(x = "Spectrum", y = "Spectrum", fun =
"character", ...) Compares two Spectrum objects. See the
above explanation for fun and .... Returns a single
numeric value.
Sebastian Gibb <mail@sebastiangibb.de>
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
bin, clean, pickPeaks,
smooth, removePeaks and trimMz
for other spectra processing methods.
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")