cascade.model.CASCADE.counterfactual

CASCADE.counterfactual(adata, batch_size=128, n_devices=1, design=None, fixed_genes=None, sample=False, ablate_latent=False, ablate_interv=False, ablate_graph=False)[source]

Counterfactual deduction for the outcome of alternative interventions for an observed dataset

Parameters:
  • adata (AnnData) – Input dataset

  • batch_size (int) – Batch size

  • n_devices (int) – Number of GPU devices to use

  • design (IntervDesign | None) – Optional intervention design module from design()

  • fixed_genes (list[str] | None) – Optional list of genes to keep their values fixed

  • sample (bool) – Whether to sample from the counterfactual distribution (True) or use the mean (False)

  • ablate_latent (bool) – If True, removes the effect of latent variables

  • ablate_interv (bool) – If True, removes the effect of interventions

  • ablate_graph (bool) – If True, removes the effect of the causal graph

Return type:

AnnData

Returns:

Counterfactual dataset with

  • layers["X_ctfact"]: Counterfactual predictions with shape (n_obs, n_vars, n_particles)

  • X: Mean values across SVGD particles