deepspatial.data_utils.compute_uot_coupling

deepspatial.data_utils.compute_uot_coupling#

deepspatial.data_utils.compute_uot_coupling(x0, g0, c0, x1, g1, c1, alpha_spatial=0.5, uot_reg=0.8, uot_tau=0.05)[source]#

Computes the Unbalanced Optimal Transport (UOT) coupling matrix between two slices.

Parameters:
  • x0 (numpy.ndarray or torch.Tensor) – Spatial coordinates for the source slice.

  • g0 (numpy.ndarray or torch.Tensor) – Gene expression matrix for the source slice.

  • c0 (numpy.ndarray or torch.Tensor) – One-hot encoded cell types for the source slice.

  • x1 (numpy.ndarray or torch.Tensor) – Spatial coordinates for the target slice.

  • g1 (numpy.ndarray or torch.Tensor) – Gene expression matrix for the target slice.

  • c1 (numpy.ndarray or torch.Tensor) – One-hot encoded cell types for the target slice.

  • alpha_spatial (float, optional) – Weight for spatial distance in the underlying cost matrix. By default 0.5.

  • uot_reg (float, optional) – Entropy regularization parameter. Higher values lead to smoother, more dispersed couplings; lower values yield sparser, more deterministic matchings. By default 0.8.

  • uot_tau (float, optional) – Marginal relaxation weight (KL divergence penalty). Controls how strictly the mass conservation is enforced. Smaller values allow more mass creation/destruction. By default 0.05.

Returns:

The calculated optimal transport coupling matrix pi of shape (N0, N1).

Return type:

numpy.ndarray