mzAlign-methods {Cardinal} | R Documentation

## Mass align an imaging dataset

### Description

Apply spectral alignment to a mass spectrometry imaging dataset.

### Usage

    ## S4 method for signature 'MSImagingExperiment,numeric'
    mzAlign(object, ref, tolerance = NA, units = c("ppm", "mz"),
            span = 0.75, control = loess.control(), ...)

    ## S4 method for signature 'MSImagingExperiment,missing'
    mzAlign(object, tolerance = NA, units = c("ppm", "mz"),
            span = 0.75, control = loess.control(), quantile = 0.2, ...)

### Arguments

`object` | An imaging dataset.
`ref` | A reference to which to align the spectra.
`tolerance` | The tolerance to be used when matching the peaks in the unaligned spectra to the reference spectrum. If this is NA, then automatically guess a tolerance from the data.
`units` | The units to use for the `tolerance`.
`span` | The smoothing parameter for the local polynomial regression used to determine the warping function.
`control` | Additional control parameters for the local polynomial regression used to determine the warping function. See `loess.control`.
`quantile` | The top quantile of reference points (peaks detected via local maxima) to use from the reference spectrum.
`...` | Ignored.

### Details

Mass alignment is performed against a vector of reference m/z values of expected peaks. The nearest local maxima to the reference peaks are detected in each unaligned spectrum (within `tolerance`), and then the unaligned spectra are warped to maximize correlation with the reference spectrum.

If no reference peaks are provided, then the mean spectrum is calculated instead, and reference peaks are selected by detecting local maxima. Some number of these reference points with the highest intensities (determined by `quantile`) are then used as the reference for alignment.

Internally, `pixelApply` is used to perform the alignment. See its documentation page for more details.

### Value

An object of the same class with the aligned spectra.

### Author(s)

Kylie A. Bemis

### See Also

`MSImagingExperiment`, `mzBin`, `peakAlign`, `pixelApply`, `process`

### Examples

    setCardinalBPPARAM(SerialParam())

    set.seed(2)
    data <- simulateImage(preset=1, npeaks=10, dim=c(3,3), sdmz=500)
    data <- data[,pData(data)$circle]

    # queue spectral alignment
    data <- mzAlign(data, tolerance=1, units="mz")

    # apply spectral alignment
    data_aligned <- process(data, plot=interactive())

[Package Cardinal version 2.8.0 Index]