Clustering

leiden_clustering(gw_mat: ndarray[Any, dtype[float64]], nn: int = 5, resolution: Optional[float] = None, seed: Optional[int] = None) ndarray[Any, dtype[int64]]

Compute clustering of cells based on GW distance, using Leiden clustering on a nearest-neighbors graph

Parameters
  • gw_mat (ndarray[Any, dtype[float64]]) – NxN distance matrix of GW distance between cells

  • nn (int) – number of neighbors in nearest-neighbors graph

  • resolution (Optional[float]) – If None, use modularity to get optimal partition. If float, get partition at set resolution.

  • seed (Optional[int]) – Seed for the random number generator. Uses a random seed if nothing is specified.

Returns

numpy array of cluster assignment for each cell

Return type

ndarray[Any, dtype[int64]]

louvain_clustering(gw_mat: ndarray[Any, dtype[float64]], nn: int) ndarray[Any, dtype[int64]]

Compute clustering of cells based on GW distance, using Louvain clustering on a nearest-neighbors graph

Parameters
  • gw_mat (ndarray[Any, dtype[float64]]) – NxN distance matrix of GW distance between cells

  • nn (int) – number of neighbors in nearest-neighbors graph

Returns

numpy array of shape (num_cells,) the cluster assignment for each cell

Return type

ndarray[Any, dtype[int64]]