Offers two different methods for smoothing noise in raw spectral data: a moving average filter and the Savitzky-Golay filter (1).

smoothSpectrum(
  dat,
  mass_dat,
  intensity_dat,
  method = NULL,
  p = NULL,
  n = NULL,
  m = 0,
  ts = 1
)

Arguments

dat

The name of the spectral data frame, containing m/z data in the first column and spectral intensity data in subsequent columns.

mass_dat

A character string; the name of the column in dat containing the m/z data for the spectrum.

intensity_dat

A character string; the name of the column in dat containing the intensity data for the spectrum to be smoothed.

method

A character string; the method to be used for smoothing. Available methods include a Savitzky-Golay filter ("sgolay") and a moving average filter ("mov_avg.")

p

Single numeric value. If method = "sgolay", the filter order of smoothing. Default = NULL.

n

Single odd numeric value. If method = "sgolay", the length of the smoothing filter. If method = "mov_avg", the window span size. Default = NULL.

m

Single numeric value. If method = "sgolay", returns the m-th derivative of the filter coefficients. Default = 0.

ts

Single numeric value. If method = "sgolay", the time scaling factor. Default = 1.

Value

Returns a new data frame containing the smoothed spectral data.

References

https://github.com/wesleyburr/subMaldi (1) A. Savitzky, M.J.E. Golay, Smoothing and differentiation of data by simplified least-squares procedures, Anal. Chem. 36 (8) (1964) 1627-1639.

Author

Kristen Yeh <kristenyeh@trentu.ca> Wesley Burr <wesleyburr@trentu.ca>

Examples

## Load sample dataset "Before1.rda" data("Before1") ## Testing method "sgolay" # test <- smoothSpectrum(dat = Before1, mass_dat = "mass", # intensity_dat = "Intensity", # method = "sgolay", p = 4, # n = 25, m = 0) ## Testing method "mov_avg" # test <- smoothSpectrum(dat = Before1, mass_dat = Before1$mass, # intensity_dat = Before1$Intensity, # method = "mov_avg", n = 25) #