mzBin-methods {Cardinal} | R Documentation

## Mass bin an imaging dataset

### Description

Apply mass binning to a mass spectrometry imaging dataset.

### Usage

    ## S4 method for signature 'MSImagingExperiment,numeric'
    mzBin(object, ref, tolerance = NA, units = c("ppm", "mz"), fun=sum, ...)

    ## S4 method for signature 'MSImagingExperiment,missing'
    mzBin(object, from=min(mz(object)), to=max(mz(object)), by,
            resolution = NA, units = c("ppm", "mz"), fun=sum, ...)

### Arguments

`object` | An imaging dataset.
`ref` | A reference to which the m/z values are binned.
`tolerance` | The half-width(s) of the bins. If this is NA, then automatically guess a resolution from the data.
`from, to` | The starting amd (maximal) end values of the sequence of m/z values.
`by` | The (approximate) interval between m/z values. For `units="ppm"`, rather than an exact step size, this actually corresponds to a binwidth, where each element of the sequence is considered the center of a bin.
`resolution` | Another way to specify the interval between m/z values. For `units="mz"`, this is the same as `by`. For `units="ppm"`, this is the half-binwdith. If this is NA, then automatically guess a resolution from the data.
`units` | The units for `by` and `resolution`. Either parts-per-million or absolute m/z increments.
`fun` | The function used to summarize each mass bin.
`...` | Ignored.

### Details

The reference masses are considered to be the center of each bin. The bin is then expanded on either side according to half the value of `width`, and the intensities in each bin are summarized by applying `fun`.

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

### Value

An object of the same class with the binned spectra.

### Author(s)

Kylie A. Bemis

### See Also

`MSImagingExperiment`, `mzAlign`, `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 m/z binning
    data <- mzBin(data, resolution=10, units="mz", fun=max)

    # apply m/z binning
    data_binned <- process(data, plot=interactive())

[Package Cardinal version 2.8.0 Index]