Implementation of the CovBat Family of harmonization methods allowing for removal of multivariate batch effects, flexible covariate modeling and alternative estimators for site effect adjustment. Support for modeling of both location and scale via GAMLSS. Additional support for modeling of covariate effects in score location and scale.
covfam( data, bat, covar =NULL, model = lm, formula =NULL, score.model =NULL, score.args =NULL, eb =TRUE, robust.LS =FALSE, ref.batch =NULL, percent.var =0.95, n.pc =NULL, std.var =TRUE,...)
Arguments
data: n x p data frame or matrix of observations where p is the number of features and n is the number of subjects.
bat: Factor indicating batch (often equivalent to site or scanner)
covar: Data frame or matrix of covariates supplied to model
model: Model function. ComBat Family supports any models that take arguments formula and data, but are limited to models fitting with identity link (e.g. family = gaussian(link = "identity")). This includes lm , gam , gamlss , rq , lmer , and more
formula: Formula for model starting with y ~ where y represents each feature
score.model: Model for scores, defaults to NULL for fitting basic location and scale model without covariates on the scores
score.args: List of arguments for score model
eb: If TRUE, uses ComBat model with empirical Bayes for mean and variance harmonization.
robust.LS: If TRUE, uses robust location and scale estimators for error variance and site effect parameters. Uses median and biweight midvariance
ref.batch: Reference batch, must take value in levels(bat)
percent.var: Numeric. The number of harmonized principal component scores is selected to explain this proportion of the variance
n.pc: Optional numeric. If specified, this number of principal component scores is harmonized. Overrides percent.var
std.var: If TRUE, scales variances to be equal to 1 before PCA.
...: Additional arguments to model
Returns
covfam returns a list containing the following components: - dat.covbat: Harmonized data as a matrix with same dimensions as data
batch.info: Batch information, including reference batch if specified
combat.out: List output of comfam from the ComBat step
pc.output: Output of prcomp from PCA step
n.pc: Numeric, number of PCs harmonized
scores.com: List output of comfam from the CovBat step
Examples
covfam(iris[,1:2], iris$Species)covfam(iris[,1:2], iris$Species, iris[3:4], lm, y ~ Petal.Length + Petal.Width)