fitIonInit: Initialize 'nls' Fitting Using Ions

View source: R/rapt_spec.R

fitIonInitR Documentation

Initialize nls Fitting Using Ions

Description

fitIonInit creates the formula and starting values for fitting mass spectra using nls based on molecular formulae. The isotopic signatures are generated using isopattern.

Usage

fitIonInit(
  ions,
  sd = 0.5,
  rel = NULL,
  peak = "gaussian",
  mass.shift = 0,
  noise = 0,
  tau = 0.1,
  charge = NULL,
  threshold = 10
)

Arguments

ions

Character. A character vector of molecular formulae sutable to be passed to isopattern.

sd

Numeric. The estimated standard deviation (or equivalent for peak = "emg") of the fitted peak.

rel

Numeric. A numeric vector of relative heights for each ion to initialize the starting values of the peak magnitudes.

peak

Character. A string specifying what sort of peak shape to fit. Acceptable values are "gaussian" (the default) and "emg". See Details.

mass.shift

Numeric. The estimated mass shift of the measured mass spectrum relative to the absolute mass position of the ions.

noise

Numeric. The estimated value of the constant noise floor of the mass spectrum.

tau

Numeric. The estimated value of the skewness parameter for peak = "emg". Ignored for peak = "gaussian".

charge

Integer. The charge(s) of the ion(s). Either a single value for all ions or a vector of values of the same length as ions. Defaults to 1

threshold

Numeric. The lowest relative

Details

The fitting peak shape is either a gaussian (peak = "gaussian") or exponentially modified gaussian (peak = "emg"). The "gaussian" peak shape is defined as

rel[i] * λ[ij] * exp(-(mass - m[ij] - mass.shift)^2 / (2 * sd ^2))

where λ[ij] is the intensity of the jth isotope of ions[i] normalized to the most intense isotope of ions[i] and m[ij] is the mass of the jth isotope of ions[i]. The "emg" peak shape is defined as

(rel[i] * λ[ij] * sd / tau) * sqrt(pi/2) * exp(1/2*(sd/tau)^2-(mass-m[j]-mass.shift)/tau) * erfc(sqrt(1/2)*(sd/tau-(mass-m[j]-mass.shift)/sd))

Value

A list containing elements of the fitting formula, the starting fit values, and the lower limits for each parameter.

See Also

nls, isopattern

Other spectral fitting functions: ionFormula()


aproudian2/rapt documentation built on Dec. 15, 2022, 4:24 a.m.