RegVelo allows you to predict the effect of a transcription factor (TF) knockout on cell fate decisions. This is done by removing the TF's outgoing edges from the GRN and recomputing the velocity field.
Workflow:
- Use
rgv.tl.in_silico_block_simulation to generate a perturbed AnnData object and a perturbed model. - Recompute the velocity kernel and fate probabilities for the perturbed system using CellRank.
- Use
rgv.mt.cellfate_perturbation to compare the perturbed results against the baseline. - Visualize the results with
rgv.pl.cellfate_perturbation.
import regvelo as rgv
import cellrank as cr
TF_candidates = ["Gabpa"]
adata_perturb_dict = {}
# 1. Simulate perturbation
for tf in TF_candidates:
adata_perturb, reg_vae_perturb = rgv.tl.in_silico_block_simulation(
model="regvelo_model", adata=adata, TF=tf, cutoff=0,
)
adata_perturb_dict[tf] = adata_perturb
# 2. Recompute fate for perturbed system
# (Assuming ct_indices is prepared from terminal states)
for tf, adata_target_perturb in adata_perturb_dict.items():
vkp = cr.kernels.VelocityKernel(adata_target_perturb).compute_transition_matrix()
estimator_p = cr.estimators.GPCCA(vkp)
estimator_p.set_terminal_states(ct_indices)
estimator_p.compute_fate_probabilities(solver="direct")
# 3. Compare and Plot
df = rgv.mt.cellfate_perturbation(perturbed=adata_perturb_dict, baseline=adata, terminal_state=TERMINAL_STATES)
rgv.pl.cellfate_perturbation(
adata=adata, df=df, fontsize=14, figsize=(8, 4),
legend_loc="center left", legend_bbox=(1.02, 0.5),
color_label="cell_type",
)