R6 class for fold-frozen per-plate (or per-batch) location-shift correction. Subtracts the per-plate median per feature, then adds back the grand median of training-plate medians, so each plate is centered without changing the overall mean. Optionally divides by a per-plate scale (IQR or MAD) before re-multiplying by the grand scale.
Details
This is intentionally simpler than FrozenComBat: it assumes
a pure location-shift (or location-and-scale) batch model and is
single-plate deployable. For ddPCR-style data where plate effects are
largely additive in log-space this is often the right tool.
Use FrozenComBat when batch effects are believed to interact
with biological covariates and an empirical-Bayes shrinkage is desirable.
Public methods
$new(scale)Constructor;
scale∈ {"none", "iqr", "mad"}.$fit(data, plate)Learn per-plate medians (and optional scales) from training data only.
$transform(data, plate)Apply frozen parameters to new data. Plates not seen during fit fall back to grand-median centering and emit a warning.
$fit_transform(data, plate)Convenience for fit + transform.
$is_fitted()Logical.
$get_plate_levels()Character vector of training plate labels.
Methods
Method new()
Construct a new os_plate_median_frozen object.
Usage
os_plate_median_frozen$new(scale = c("none", "iqr", "mad"))Method transform()
Apply frozen correction to new data.
Examples
set.seed(7)
plate <- rep(c("P1", "P2", "P3"), each = 10)
x <- matrix(rnorm(60, mean = 0, sd = 0.5), nrow = 30)
x[plate == "P2", ] <- x[plate == "P2", ] + 3
x[plate == "P3", ] <- x[plate == "P3", ] - 2
fc <- os_plate_median_frozen$new()
fc$fit(x[1:24, ], plate[1:24])
corrected <- fc$transform(x[25:30, ], plate[25:30])