scHopfield.tools.compute_energies

scHopfield.tools.compute_energies(adata: AnnData, spliced_key: str = 'Ms', degradation_key: str = 'gamma', cluster_key: str = 'cell_type', copy: bool = False) AnnData | None[source]

Calculate energy landscapes for all clusters.

Computes total energy and its components (interaction, degradation, bias) for each cell based on the inferred gene regulatory network.

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

  • spliced_key (str, optional (default: 'Ms')) – Key in adata.layers for spliced counts

  • degradation_key (str, optional (default: 'gamma')) – Key in adata.var for degradation rates

  • copy (bool, optional (default: False)) – If True, return a copy instead of modifying in-place

Returns:

Returns adata if copy=True, otherwise None. Adds to adata.obs: - ‘energy_total’ - ‘energy_interaction’ - ‘energy_degradation’ - ‘energy_bias’

Each cell’s energy is computed using cluster-specific parameters.

Return type:

AnnData or None

Notes

Energy formula: E = -0.5 * s^T W s + gamma * integral(sigmoid^-1) - I^T s