estimateFwhm: Estimation of fwhm as a function of m/z axis

View source: R/estimateFwhm.R

estimateFwhmR Documentation

Estimation of fwhm as a function of m/z axis

Description

This creates a linear interpolator function that approximats fwhm as a function of m/z for the given single spectrum or a list of mass spectra.

Usage

estimateFwhm(
  s,
  spectraSampling = 10,
  peakSampling = 1000,
  numCores = 1,
  smoothingMethod = "loess",
  SNR = 5,
  plot = FALSE,
  savePlot = NULL
)

Arguments

s:

a single profile (continuous) spectrum of type 'MALDIquant::MassSpectrum' of a list thereof. This could also be a list of 'MALDIquant::MassPeaks' object but with conditions, see Details.

spectraSampling:

an integer specifying how many spectra should be used for fwhm estimation (the lower the faster) when 's' is a list of 'MALDIquant::MassSpectrum' objects. Defaults to 99.

peakSampling:

an integer specifying how many detected peaks (in each spectrum) to consider for fwhm estimation, the lower the faster. Defaults to 99.

numCores:

an integer specifying the number of cores used for the FWHM computations when s is a 'MassSpectrum' or a list thereof. This is ignored on windows.

smoothingMethod:

a character, one of ‘c(’loess','superSmoother')', the method that is used for fitting a smoothing curve to represent fwhm as a function of m/z. Defaults to 'loess' which produced better fits but takes longer to compute.

SNR:

an optional numeric, the minimum SNR level of the peaks that are used for fwhm estimation.

plot:

whether to plot the result.

savePlot:

either NULL or file path to save a plot as svg.

Details

The input 's' could be a single profile (continuous) 'MassSpectrum' object. This could be supplied externally or via 'readSingleSpect' function (see '?readSingleSpect'). This is normally the case when dealing with MRMS (FTICR) centroided data which does not contain any information about peaks FWHM values (for example when read from a centroided imzML file).

's' could also be a list of 'MassSpectrum' objects. This could be the case when dealing with continuous TOF data. In this case, the list of spectra is sampled and FWHM values are computed based on these.

If 's' is a list of centroided 'MassPeaks' objects, the function assumes that FWHM values have been (externally) pre-computed and attached to each centroided spectrum ('MassPeaks' object) via the 'metaData' slot (see '?MALDIquant::MassPeaks') such that for every centroided spectrum 's[[i]]' the FWHM values corresponding to all detected peaks 's[[i]]@mass' are stored in 's[[i]]@metaData$fwhm'.

Value

Returns an S3 object 'fwhm' containing a linear interplotor function 'fwhmInterpolator' in addition to m/z values of the peaks and their corresponding fwhm values.


CeMOS-Mannheim/moleculaR documentation built on April 14, 2025, 8:27 a.m.