Skip to contents

Bins spectral data generated by Cardinal from a matter object to a Matrix object

Usage

bin_cardinal(
  x,
  ref,
  spectra = "intensity",
  index = "mz",
  method = c("sum", "mean", "max", "min", "linear", "cubic", "gaussian", "lanczos"),
  resolution = NA,
  tolerance = NA,
  units = c("ppm", "mz"),
  mass.range = NULL
)

Arguments

x

The spectral data to be binned, typically a matrix or data frame.

ref

A vector of reference mass-to-charge (m/z) values for binning. If left unspecified, mass range will be used to generate reference peaks.

spectra

Character string specifying the column name for spectral intensity values (default = "intensity").

index

Character string specifying the column name for the m/z values (default = "mz").

method

A character vector specifying the binning method. Options include "sum", "mean", "max", "min", "linear", "cubic", "gaussian", and "lanczos". If not specified default method used is "sum".

resolution

Numeric value specifying the resolution for binning. If assigned as NA, the resolution will be automatically caculated based on the data (default = NA).

tolerance

Numeric value specifying the tolerance for m/z matching (default = NA).

units

Character string specifying the units for resolution. Options are "ppm" or "mz" (default = "ppm").

mass.range

Numeric vector of length two specifying the lower and upper bounds of the mass range for binning. If set to NULL will use the entire range to bin (default = NULL).

Value

A binned spectral data object with the same structure as the input, but with modified spectral data according to the specified binning parameters.

Examples

# used as a helper function for LoadSM