deepspatial.data_utils.compute_cost_matrix

deepspatial.data_utils.compute_cost_matrix#

deepspatial.data_utils.compute_cost_matrix(x0, g0, c0, x1, g1, c1, alpha_spatial=0.5)[source]#

Computes a hybrid cost matrix balancing spatial distance, gene expression, and cell types.

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

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

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

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

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

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

  • alpha_spatial (float, optional) – Weight balancing the spatial vs. gene distance (between 0 and 1). By default 0.5.

Returns:

The combined cost matrix of shape (N0, N1).

Return type:

numpy.ndarray