cossim: Calculate cosine similarity between two spectra

View source: R/classes_methods.R

cossimR Documentation

Calculate cosine similarity between two spectra

Description

cossim() calculates the cosine of the spectral constrast angle as a measure for the similarity of two spectra.

Usage

cossim(x, y, type = c("spectrum", "neutral_losses"),
    mzTolerance = 1e-05)

## S4 method for signature 'MS2spectrum,MS2spectrum'
cossim(x, y, type = c("spectrum",
    "neutral_losses"), mzTolerance = 1e-05)

## S4 method for signature 'pseudospectrum,pseudospectrum'
cossim(x, y,
    type = c("spectrum", "neutral_losses"), mzTolerance = 1e-05)

Arguments

x, y

MS2 spectra, either as matrix, MS2spectrum or pseudospectrum objects. x and y must have the same class.

type

Whether similarity between spectra ("spectrum", default) or neutral loss patterns ("neutral_losses") is to be compared

mzTolerance

The m/z tolerance used for merging. If two fragment peaks are within tolerance, they are regarded as the same. Defaults to 1e-5, i.e. 10ppm.

Value

The cosine similarity of x and y

Methods (by class)

  • x = MS2spectrum,y = MS2spectrum: cossim method for MS2spectrum objects

  • x = pseudospectrum,y = pseudospectrum: cossim method for pseudospectrum objects

Examples

load(file = system.file("extdata",
    "annotatedSpeclist.RData",
    package = "CluMSIDdata"))

cossim(annotatedSpeclist[[1]], annotatedSpeclist[[2]])


tdepke/CluMSID documentation built on April 10, 2022, noon