View source: R/causal_ccombat.R
cb.correct.matching_cComBat | R Documentation |
A function for implementing the matching conditional ComBat (matching cComBat) algorithm. This algorithm allows users to remove batch effects (in each dimension), while adjusting for known confounding variables. It is imperative that this function is used in conjunction with domain expertise (e.g., to ensure that the covariates are not colliders, and that the system could be argued to satisfy the ignorability condition) to derive causal conclusions. See citation for more details as to the conditions under which conclusions derived are causal.
cb.correct.matching_cComBat(
Ys,
Ts,
Xs,
match.form,
covar.out.form = NULL,
prop.form = NULL,
reference = NULL,
match.args = list(method = "nearest", exact = NULL, replace = FALSE, caliper = 0.1),
retain.ratio = 0.05,
apply.oos = FALSE
)
Ys |
an |
Ts |
|
Xs |
|
match.form |
A formula of columns from |
covar.out.form |
A covariate model, given as a formula. Applies for the outcome regression step of the |
prop.form |
A propensity model, given as a formula. Applies for the estimation of propensities for the propensity trimming step. Defaults to |
reference |
the name of the reference/control batch, against which to match. Defaults to |
match.args |
A named list arguments for the |
retain.ratio |
If the number of samples retained is less than |
apply.oos |
A boolean that indicates whether or not to apply the learned batch effect correction to non-matched samples that are still within a region of covariate support. Defaults to |
a list, containing the following:
Ys.corrected
an [m, d]
matrix, for the m
retained samples in d
dimensions, after correction.
Ts
[m]
the labels of the m
retained samples, with K < n
levels.
Xs
the r
covariates/confounding variables for each of the m
retained samples.
Model
the fit batch effect correction model. See ComBat
for details.
InSample.Ids
the ids which were used to fit the batch effect correction model.
Corrected.Ids
the ids to which batch effect correction was applied. Differs from InSample.Ids
if apply.oos
is TRUE
.
For more details see the help vignette:
vignette("causal_ccombat", package = "causalBatch")
Eric W. Bridgeford
Eric W. Bridgeford, et al. "A Causal Perspective for Batch Effects: When is no answer better than a wrong answer?" Biorxiv (2024).
Daniel E. Ho, et al. "MatchIt: Nonparametric Preprocessing for Parametric Causal Inference" JSS (2011).
W Evan Johnson, et al. "Adjusting batch effects in microarray expression data using empirical Bayes methods" Biostatistics (2007).
Leek JT, Johnson WE, Parker HS, Fertig EJ, Jaffe AE, Zhang Y, Storey JD, Torres LC (2024). sva: Surrogate Variable Analysis. R package version 3.52.0.
library(causalBatch)
sim <- cb.sims.sim_linear(a=-1, n=100, err=1/8, unbalancedness=2)
cb.correct.matching_cComBat(sim$Ys, sim$Ts, data.frame(Covar=sim$Xs), "Covar")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.