distanceMatrix {CluMSID} | R Documentation

## Create distance matrix from list of spectra

### Description

`distanceMatrix()` creates a distance matrix from a list of MS2 spectra, MS1 pseudospectra or neutral loss patterns by pairwise comparison using the specified distance function. This distance matrix is the basis for CluMSID's data mining functions.

### Usage

    distanceMatrix(speclist, distFun = "cossim", type = c("spectrum",
        "neutral_losses"), mz_tolerance = 1e-05)

### Arguments

`speclist` | A list of `MS2spectrum` or `pseudospectrum` objects as generated by `extractMS2spectra` or `extractPseudospectra`.
`distFun` | The distance function to be used. At the moment, only `cossim` is implemented.
`type` | `"spectrum"` (default) for MS2 spectra or MS1 pseudospectra or `"neutral_losses"` for neutral loss patterns.
`mz_tolerance` | The m/z tolerance to be used for merging, default is `1e-5`, i.e. +/- 10ppm. If the mass-to-charge ratios of two peaks differ less than mz_tolerance, they are assumed to have the same m/z

### Value

A numeric `length(speclist)` by `length(speclist)` matrix containing pairwise distances (1 - similarity) between all features in `speclist`. Row and column names are taken from the `id` slot or, if present, pasted from the `id` and `annotation` slots of the `MS2spectrum` or `pseudospectrum` objects.

### Examples

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

    distanceMatrix(annotatedSpeclist[1:20])

[Package CluMSID version 1.10.0 Index]