scHopfield.dynamics.compare_perturbations

scHopfield.dynamics.compare_perturbations(adata: AnnData, perturbations: Dict[str, Dict[str, float]] | List[Dict[str, float]], labels: List[str] | None = None, cluster_key: str = 'cell_type', target_clusters: List[str] | None = None, n_propagation: int = 3, dt: float = 1.0, verbose: bool = True) DataFrame[source]

Compare multiple perturbation conditions.

Parameters:
  • adata (AnnData) – Annotated data object with fitted interactions

  • perturbations (dict or list) – Either: - Dict mapping labels to perturbation conditions: {“KO”: {“Gata1”: 0.0}, “OE”: {“Gata1”: 1.0}} - List of perturbation conditions (requires labels parameter)

  • labels (list of str, optional) – Labels for each perturbation. Required if perturbations is a list. Ignored if perturbations is a dict (keys are used as labels).

  • cluster_key (str, optional (default: 'cell_type')) – Key in adata.obs for cluster labels

  • target_clusters (list of str, optional) – List of cluster names to simulate perturbation in. If None, simulates in all clusters.

  • n_propagation (int, optional (default: 3)) – Number of propagation steps

  • dt (float, optional (default: 1.0)) – Scaling factor for each propagation step

  • verbose (bool, optional (default: True)) – Whether to show progress

Returns:

DataFrame with genes as index and mean |delta_X| for each perturbation condition

Return type:

pd.DataFrame

References

Logic for the transition vector field is inspired by the perturbation simulation workflow in CellOracle: Kamimoto et al. (2023). Nature. https://doi.org/10.1038/s41586-022-05688-9