mergeMS2spectra {CluMSID} | R Documentation

## Merge MS2 spectra with or without external peak table

### Description

`mergeMS2spectra` is used to merge MS2 spectra that come from the same precursor. It does so either by grouping spectra of the same precursor m/z that fall into a defined retention time window (`rt_tolerance`) or by grouping spectra to peaks from an externally supplied peak table. Please see the vignette for more details.

### Usage

    mergeMS2spectra(ms2list, mz_tolerance = 1e-05, rt_tolerance = 30,
        peaktable = NULL, exclude_unmatched = FALSE)

### Arguments

`ms2list` | A `list` of `MS2spectrum` objects to be merged.
`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
`rt_tolerance` | The retention time tolerance used for merging features. If used without a peak table, `rt_tolerance` is the maximum retention time difference between to subsequent spectra of the same precursor m/z with which they are still assumed to belong to the same feature If used with an external peak table, `rt_tolerance` is the maximum retention time difference between a spectrum and a peak in the peak table with which the spectrum is still considered to belong to that peak.
`peaktable` | An external peak table, e.g. from XCMS, that serves as a template for grouping spectra. The peaktable must be a three-column `data.frame` with feature ID, m/z and retention time for each peak/feature.
`exclude_unmatched` | If an external peak table is used: Should spectra that do not match to any peak/feature in the peak table be exclude from the resulting list?

### Value

A merged list of `MS2spectrum` objects.

### Examples

    my_spectra <- extractMS2spectra(MSfile = system.file("extdata",
                                    "PoolA_R_SE.mzXML",
                                    package = "CluMSIDdata"),
                                    min_peaks = 4, RTlims = c(0,5))

    my_merged_spectra <- mergeMS2spectra(my_spectra, rt_tolerance = 20)

[Package CluMSID version 1.0.0 Index]