
Fit Train/Test-Safe Empirical Bayes ComBat Harmonisation Parameters
Source:R/combat.R
combat_fit.RdEstimates batch location and scale parameters on a training cohort while
preserving biological covariates (mod). Apply the resulting fit to
training or held-out test cohorts with combat_apply() without test-set
leakage.
Arguments
- features
Numeric matrix (
n_features x n_samples).- batch
Factor or character vector of scanner/site batch labels of length
ncol(features).- mod
Optional biological covariate design matrix (
n_samples x q, e.g. frommodel.matrix(~ age + sex)).- eb
Logical; if
TRUE(default), applies Empirical Bayes shrinkage across features.- ref_batch
Optional reference batch name.