scHopfield.tools.validate_velocity

scHopfield.tools.validate_velocity(adata: AnnData, velocity_key: str = 'velocity', spliced_key: str = 'Ms', degradation_key: str = 'gamma', cluster_key: str = 'cell_type', return_mse: bool = True) float | dict[source]

Validate reconstructed velocity against original velocity.

Computes mean squared error between Hopfield model predictions and original RNA velocity estimates.

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

  • velocity_key (str, optional (default: 'velocity')) – Key in adata.layers for original velocity

  • 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

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

  • return_mse (bool, optional (default: True)) – If True, returns overall MSE. If False, returns dict with per-cluster MSE values

Returns:

Overall MSE (if return_mse=True) or dict mapping cluster names to their MSE values (if return_mse=False)

Return type:

float or dict