Learn R Programming

TargetSearch (version 1.28.1)

baselineCorrection: Baseline correction algorithm

Description

Functions for baseline correction of GC-MS chromatograms.

Usage

baselineCorrection(int, threshold = 0.5, alpha = 0.95, bfraction = 0.2, segments = 100, signalWindow = 10, method = "linear") baseline(ncData, baseline.opts = NULL)

Arguments

int
A matrix object of spectra peak intensities to be baseline corrected, where the columns are retention times and rows mass traces.
threshold
A numeric value between 0 and 1. A value of one sets the baseline above the noise, 0.5 in the middle of the noise and 0 below the noise.
alpha
The alpha parameter of the high pass filter.
bfraction
The percentage of the fragments with the lowest intensities of the filtered signal that are assumed to be baseline signal.
segments
The number of segments in which the filtered signal is divided.
signalWindow
The window size (number of points) used in the signal windowing step.
method
The method used to approximate the baseline. "linear" (default) uses linear interpolation. "spline" fits a cubic smoothing spline (warning: really slow).
ncData
A list returned by the function xcms:::netCDFRawData
baseline.opts
A list with parameters to be passed to baselineCorrection function. For example baseline.opts = list(threshold = 0.5, alpha = 0.95).

Value

A matrix of the same dimensions of int with the baseline corrected intensities.

Details

The baseline correction algorithm is based on the work of Chang et al, and it works as follows. For every mass trace, i.e., rows of matrix int, the signal intensity is filtered by a first high pass filter: y[i] = alpha * (y[i-1] + x[i] - x[i-1]). The filtered signal is divided into evenly spaced segments (segments) and the standard deviation of each segment is calculated. A percentage (bfraction) of the segments with the lowest values are assumed to be baseline signal and the standard deviation (stdn) of the points within those segments is calculated.

Once stdn has been determined, the points with absolute filtered values larger than 2 * stdn are considered signal. After that, the signal windowing step takes every one of the points found to be signal as the center of a signal window (signalWindow) and marks the points within that window as signal. The remaining points are now considered to be noise.

The baseline signal is obtained by either using linear interpolation (default) or fitting a cubic smoothing spline taking only the noise. The baseline can be shifted up or down by using the parameter (threshold), which is done by the formula: B' = B + 2*(threshold - 0.5)*2*stdn, where B is the fitted spline, stdn the standard deviation of the noise, and threshold a value between 0 and 1. Finally, the corrected signal is calculated by subtracting B' to the original signal. The baseline function is called by the function NetCDFPeakFinding before the peak picking algorithm is performed. Since it is an internal function, it is not intended to be executed directly.

References

David Chang, Cory D. Banack and Sirish L. Shah, Robust baseline correction algorithm for signal dense NMR spectra. Journal of Magnetic Resonance 187 (2007) 288-292

See Also

RIcorrect