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"),
            quantile = 0.2, span = 0.75, ...)

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

### Arguments

`object` | An imaging dataset.
`ref` | A reference spectrum to use for alignment.
`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`.
`quantile` | The top quantile of reference points (peaks detected via local maxima) to use from the reference spectrum.
`span` | The smoothing parameter for the local polynomial regression used to determine the warping function.
`...` | Ignored.

### Details

Mass binning is performed by first selecting reference points in the reference spectrum by detecting local maxima. Some number of these reference points with the highest intensities (determined by `quantile`) are then used for alignment. The nearest local maxima to the reference points are detected in each unaligned spectrum (within `tolerance`), and then the unaligned spectra are warped to maximize correlation with the reference spectrum.

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

    register(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.4.0 Index]