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,
...
)
covfam
returns a list containing the following components:
Harmonized data as a matrix with same dimensions as data
Batch information, including reference batch if specified
List output of comfam
from the ComBat step
Output of prcomp
from PCA step
Numeric, number of PCs harmonized
List output of comfam
from the CovBat step
n x p data frame or matrix of observations where p is the number of features and n is the number of subjects.
Factor indicating batch (often equivalent to site or scanner)
Data frame or matrix of covariates supplied to 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 for model
starting with y ~
where y
represents
each feature
Model for scores, defaults to NULL for fitting basic location and scale model without covariates on the scores
List of arguments for score model
If TRUE
, uses ComBat model with empirical Bayes for mean
and variance harmonization.
If TRUE
, uses robust location and scale estimators
for error variance and site effect parameters. Uses median and
biweight midvariance
Reference batch, must take value in levels(bat)
Numeric. The number of harmonized principal component scores is selected to explain this proportion of the variance
Optional numeric. If specified, this number of principal
component scores is harmonized. Overrides percent.var
If TRUE
, scales variances to be equal to 1 before PCA.
Additional arguments to model
covfam(iris[,1:2], iris$Species)
covfam(iris[,1:2], iris$Species, iris[3:4], lm, y ~ Petal.Length + Petal.Width)
Run the code above in your browser using DataLab