peakAlign-methods {Cardinal} | R Documentation

## Peak align an imaging dataset

### Description

Apply peak alignment to a mass spectrometry imaging dataset.

### Usage

    ## S4 method for signature 'MSImagingExperiment,missing'
    peakAlign(object, tolerance = NA, units = c("ppm", "mz"), ...)

    ## S4 method for signature 'MSImagingExperiment,character'
    peakAlign(object, ref, ...)

    ## S4 method for signature 'MSImagingExperiment,numeric'
    peakAlign(object, ref, ...)

    ## S4 method for signature 'MSImageSet,numeric'
    peakAlign(object, ref, method = c("diff", "DP"),
        ...,
        pixel = pixels(object),
        plot = FALSE)

    ## S4 method for signature 'MSImageSet,MSImageSet'
    peakAlign(object, ref, ...)

    ## S4 method for signature 'MSImageSet,missing'
    peakAlign(object, ref, ...)

    ## Absolute difference alignment
    peakAlign.diff(x, y, diff.max=200, units=c("ppm", "mz"), ...)

    ## Dynamic programming alignment
    peakAlign.DP(x, y, gap=0, ...)

### Arguments

`object` | An imaging dataset.
`ref` | A reference to which to align the peaks.
`tolerance` | The tolerance to be used when aligning detected peaks to the reference. If this is NA, then automatically guess a tolerance from the data.
`units` | The units to use for the `tolerance`. Either parts-per-million or the raw m/z values.
`method` | The peak alignment method to use.
`pixel` | The pixels to align. If less than the extent of the dataset, this will result in a subset of the data being processed.
`plot` | Plot the mass spectrum for each pixel while it is being processed?
`...` | Additional arguments passed to the peak alignment method.
`x` | The vector of m/z values to be aligned.
`y` | The vector of reference m/z values.
`diff.max` | Peaks that differ less than this value will be aligned together.
`gap` | The gap penalty for the dynamic programming sequence alignment.

### Details

When applied to a `MSImagingExperiment` object with no other reference, `peakAlign` uses `summarize()` to calculate the mean spectrum, and then uses the local maxima of the mean spectrum as the reference. Alternatively, a vector of m/z values or a column name in the featureData that should be used as the reference may be provided. Finally, if the featureData has an numeric vector element named “reference peaks” among its `metadata()`, this vector is used as the reference.

When applied to a `MSImageSet` object, if a `MSImageSet` object is used as the reference then the local maxima in its mean spectrum will be calculated and used as the reference m/z values. The method looks for a “mean” column in the object's `featureData`, and if it does not exist, then the mean spectrum will be calculated using `featureApply(ref, mean)`. If the reference is missing, the method will use the object itself as the reference.

Peak alignment is usually performed using the provided functions, but a user-created function can also be passed to `method`. In this case it should take the following arguments:

- `x`: The vector of m/z values to be aligned.

- `y`: The vector of reference m/z values.

- `...`: Additional arguments.

A user-created function should return a vector of the same length as `x` and `y` where `NA` values indicate no match, and non-missing values give the index of the matched peak in the reference set.

Internally, `pixelApply` is used to apply the peak alignment. See its documentation page for more details on additional objects available to the environment installed to the peak alignment function.

### Value

An object of class `MSImageSet` with the peak aligned spectra.

### Author(s)

Kylie A. Bemis

### See Also

`MSImagingExperiment`, `MSImageSet`, `peakPick`, `peakFilter`, `peakBin`, `reduceDimension`, `pixelApply`, `process`

### Examples

    setCardinalBPPARAM(SerialParam())

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

    # queue peak picking and alignment
    data <- peakPick(data, method="simple", SNR=6)
    data <- peakAlign(data, tolerance=200, units="ppm")

    # apply peak picking and alignment
    data_peaks <- process(data, plot=interactive())

[Package Cardinal version 2.8.0 Index]