Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/BaselineCorrection.R
The function estimates and removes the smoothed baseline from the spectra.
1 2 3 4 |
Spectrum_data |
Matrix containing the spectra, one row per spectrum. |
ptw.bc |
If |
maxIter |
Maximum number of iterations for the R version (if |
lambda.bc |
Smoothing parameter (generally 1e5 – 1e8). See details. |
p.bc |
Asymmetry parameter. See details. |
eps |
Numerical precision for convergence when estimating the baseline. |
ppm.bc |
If |
exclude.bc |
If not |
returnBaseline |
If |
verbose |
If |
The signal should be an addition of positive peaks which represent metabolites from the samples. These peaks are added to the baseline which is the signal representing the absence of any metabolite and should therefore be uniformly zero. For each spectrum, its baseline is thus estimated and removed. Let F be our initial spectrum an Z be its baseline. Once Z is approximated, the corrected spectrum is F - Z.
A negative signal doesn't make sense and creates problems with the statistical analysis. The estimated baseline should then not be such that F - Z < 0.
Hence, in the objective function to be minimized, the squared difference F-Z are weighted by p if F - Z > 0 or 1 - p if F - Z < 0.
p is indeed taken very small, e.g. 0.05
, to avoid negative intensities. The function NegativeValuesZeroing
is used thereafter to set the remaining negative intensities to zero after the baseline correction.
With this function to minimize, we would simply have F = Z as a solution which would make F - Z uniformly zero. Therefore, a roughness penalty term on Z is applied so that it does not match exactly the peaks.
The importance of this smoothness constraint in the objective function is tuned by λ which is typically equal to 1e7
.
In summary, usefull parameters are:
p.bc
The default value is 0.05
. The smaller it is, the less Z will try to follow peaks when it is under the function and the more it will try to be under the function.
lambda.bc
The default value is 1e7
. The larger it is, the smoother Z will be.
With lambda = 0
, the baseline will be equal to the signal and the corrected signal will be zero.
The algorithm used to find the baseline is iterative. In ptw
, the iteration is done until the baseline is found but if ptw.bc
is set to FALSE
, we stop after maxIter
iterations.
More details and motivations are given in the articles mentionned in the References.
If returnBaseline
is TRUE
, will return a list with the following elements: Spectrum_data
and Baseline
. Otherwise, the function will just return Spectrum_data
.
Spectrum_data |
The matrix of spectra with the baseline removed. |
Baseline |
Estimation of the baseline. |
Benoît Legat, Manon Martin & Paul H. C. Eilers
Martin, M., Legat, B., Leenders, J., Vanwinsberghe, J., Rousseau, R., Boulanger, B., & Govaerts, B. (2018). PepsNMR for 1H NMR metabolomic data pre-processing. Analytica chimica acta, 1019, 1-13.
Rousseau, R. (2011). Statistical contribution to the analysis of metabonomics data in 1H NMR spectroscopy (Doctoral dissertation, PhD thesis. Institut de statistique, biostatistique et sciences actuarielles, Université catholique de Louvain, Belgium).
Eilers, PHC. and Boelens, HFM. (2005). Baseline correction with asymmetric least squares smoothing. Leiden University Medical Centre report, 2005.
See also SolventSuppression
which also uses the Whittaker smoother.
1 2 3 4 5 6 7 8 | require(PepsNMRData)
BC_res <- BaselineCorrection(Data_HS_sp$Spectrum_data_HS_5,
lambda.bc=5e+06, p.bc=0.05)
#or
BC_res <- BaselineCorrection(Data_HS_sp$Spectrum_data_HS_5,
lambda.bc=5e+06, p.bc=0.05, returnBaseline=TRUE)
BC_spec = BC_res[["Spectrum_data"]]
plot(BC_res[["Baseline"]], type="l")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.