getSpectrum {CluMSID} | R Documentation

## Access individual spectra from a list of spectra by various slot entries

### Description

As accessing S4 objects within lists is not trivial, `getSpectrum` can be used to access individual or several `MS2spectrum` objects by their slot entries.

### Usage

    getSpectrum(featlist, slot, what, mz.tol = 1e-05, rt.tol = 30)

### Arguments

`featlist` | a list that contains only objects of class `MS2spectrum`
`slot` | The slot to be searched (invalid slot arguments will produce errors). Possible values are: `'id'` `'annotation'` `'precursor'` (m/z of precursor ion) `'rt'` (retention time of precursor)
`what` | the search term or number, must be character for `'id'` and `'annotation'` and numeric for `'precursor'` and `'rt'` See vignette for examples.
`mz.tol` | the tolerance used for precursor ion *m/z* searches, defaults to `1E-05` (+/- 10ppm)
`rt.tol` | the tolerance used for precursor ion retention time searches, defaults to 30s; high values can be used to specify retention time ranges (see vignette for example)

### Value

If the only one spectrum matches the search criteria, the output is an object of class `MS2spectrum`; if more than one spectrum matches, the output is a list of `MS2spectrum` objects.

### Examples

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

    getSpectrum(annotatedSpeclist, "annotation", "pyocyanin")

    getSpectrum(annotatedSpeclist, "id", "M244.17T796.4")

    getSpectrum(annotatedSpeclist, "precursor", 286.18, mz.tol = 1E-03)

    six_eight <- getSpectrum(annotatedSpeclist, "rt", 420, rt.tol = 60)

[Package CluMSID version 1.0.0 Index]