Drift and batch correction
Source:vignettes/articles/manual-07-corrections.Rmd
manual-07-corrections.RmdManual
MRMhub provides functions for run-order drift and batch correction.
The correction is based on user-selected reference sample types
(ref_qc_types), relative to which all other samples are
adjusted. The corrections can be applied to intensity,
norm_intensity, or conc data.
Which samples a correction is fitted on depends on the modelling
method. The QC-based smoothers (correct_drift_loess(),
correct_drift_cubicspline()) are fitted on the reference
sample types selected with ref_qc_types, typically QC
samples, i.e. the batch QC (BQC), or the technical QC
(TQC) in case of clear instrument drifts, following the
QC-based paradigm (Broadhurst et al.
2018). The gaussian-kernel method
(correct_drift_gaussiankernel()) instead fits on the study
samples and is only appropriate for large, well-randomised cohorts.
Drift correction (smoothing)
The following drift correction methods are available in MRMhub, two of which are typically used for QC samples and one (gaussian kernel-based) for study samples.
Corrections can be applied on a batch-by-batch basis
(batch_wise = TRUE, default) or across all batches
(batch_wise = FALSE). The correction can either replace
existing drift or batch corrections
(replace_previous = TRUE, default) or applied on top of
existing corrections (replace_previous = FALSE).
Drift correction can be applied to all features
(conditional_correction = FALSE) or conditionally, based on
whether the sample CV difference before and after correction is below a
defined threshold (cv_diff_threshold). The conditional
correction is applied separately for each batch if
batch_wise = TRUE.
It is recommended to visually inspect the correction using the
plot_runscatter() function. Set the argument
recalc_trend_after = TRUE so that the trends after
correction are also available for plotting. For further details, refer
to the description of plot_runscatter(). This, however,
doubles the processing time.
The function outputs a message indicating the median CV change and the mean absolute CV before and after correction for all samples. However, these metrics are experimental and should not be used as definitive criteria for correction (see function documentation).
| Method | Function | Details |
|---|---|---|
| Cubic Spline | correct_drift_cubicspline() |
Smoothing parameter determined via cross-validation or set as fixed. Typically used with QC samples as reference. |
| Loess | correct_drift_loess() |
Loess smoothing with fixed span. Typically used with QC samples as reference. |
| Gaussian Kernel | correct_drift_gaussiankernel() |
Fixed kernel size. Option to smooth scale (variability). Typically used with study samples as reference. Only suitable for large, well-randomized sample sets. |
The cubic spline smoothing approach, particularly when used with the
regularization parameter lambda, is similar but not
identical to previously described QC-based drift correction methods,
such as QC-RSC (Quality Control Regularized Spline
Correction), described in Dunn et al.
(2011) and Kirwan et al.
(2013).
See the tutorial Drift and batch correction for more information on how to use these functions and plot the results.
Batch-effect correction
MRMhub provides three batch-correction methods. Batch correction is applied after normalization and, where used, drift correction.
-
Median centering
(
correct_batch_centering()) aligns the per-batch medians of the selected QC types (ref_qc_types), following the QC-based paradigm (Broadhurst et al. 2018); the scale of the batches can optionally also be equalized. This is the default, most robust choice. -
ComBat (
correct_batch_combat()) applies the empirical-Bayes location and scale model of Johnson et al. (2007), shrinking the batch estimates across features. Unlike the other two methods, ComBat estimates batch effects from all samples rather than from the reference QCs; supplycovariatesto protect biological signal on unbalanced designs. -
SERRF (
correct_batch_serrf()) removes systematic error with per-feature random forests trained on the reference QCs, using each feature’s most correlated features as predictors (Fan et al. 2019). It captures non-linear batch and drift effects jointly and is best suited to larger panels with dense QC coverage.
correct_batch_combat() and
correct_batch_serrf() are experimental.
ComBat requires the optional sva package and SERRF the
optional ranger package. The SERRF implementation adapts
the reference code in the malbacR package (Leach et al. 2023); validate results against
the reference implementation for your data.
See the tutorial Drift and batch correction for more information.
Next steps
- Drift and batch correction (tutorial): worked examples of both corrections
- Exploring QC: RunScatter and PCA: visualise run-order and batch effects