cb.correct.aipw_cComBat: Augmented Inverse Probability Weighting Conditional ComBat

View source: R/causal_ccombat.R

cb.correct.aipw_cComBatR Documentation

Augmented Inverse Probability Weighting Conditional ComBat

Description

A function for implementing the AIPW conditional ComBat (AIPW 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.

Usage

cb.correct.aipw_cComBat(
  Ys,
  Ts,
  Xs,
  aipw.form,
  covar.out.form = NULL,
  retain.ratio = 0.05
)

Arguments

Ys

an [n, d] matrix, for the outcome variables with n samples in d dimensions.

Ts

[n] the labels of the samples, with at most two unique batches.

Xs

[n, r] the r covariates/confounding variables, for each of the n samples, as a data frame with named columns.

aipw.form

A covariate model, given as a formula. Applies for the estimation of propensities for the AIPW step.

covar.out.form

A covariate model, given as a formula. Applies for the outcome regression step of the ComBat algorithm. Defaults to NULL, which re-uses aipw.form for the covariate/outcome model.

retain.ratio

If the number of samples retained is less than retain.ratio*n, throws a warning. Defaults to 0.05.

Details

Note: This function is experimental, and has not been tested on real data. It has only been tested with simulated data with binary (0 or 1) exposures.

Value

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.

  • Corrected.Ids the ids to which batch effect correction was applied.

Details

For more details see the help vignette: vignette("causal_ccombat", package = "causalBatch")

Author(s)

Eric W. Bridgeford

References

Eric W. Bridgeford, et al. "A Causal Perspective for Batch Effects: When is no answer better than a wrong answer?" Biorxiv (2024).

W Evan Johnson, et al. "Adjusting batch effects in microarray expression data using empirical Bayes methods" Biostatistics (2007).

Examples

library(causalBatch)
sim <- cb.sims.sim_linear(a=-1, n=100, err=1/8, unbalancedness=2)
cb.correct.aipw_cComBat(sim$Ys, sim$Ts, data.frame(Covar=sim$Xs), "Covar")


causalBatch documentation built on April 3, 2025, 8:38 p.m.