rapids_singlecell.gr.interaction_matrix#
- rapids_singlecell.gr.interaction_matrix(adata, cluster_key, *, table_key=None, connectivity_key='spatial_connectivities', normalized=False, weights=False, copy=False)[source]#
Compute the interaction matrix for clusters.
Counts the spatial graph edges between every pair of clusters. Cells whose cluster label is missing are removed together with their edges.
- Parameters:
- adata
AnnData|SpatialData Annotated data matrix or a SpatialData object containing the selected table.
- cluster_key
str Key in
anndata.AnnData.obswith categorical cluster labels.- table_key
str|None(default:None) Key in
SpatialData.tables; required for SpatialData input. Ignored for AnnData input.- connectivity_key
str(default:'spatial_connectivities') Key in
anndata.AnnData.obspwith the spatial connectivity graph.- normalized
bool(default:False) If
True, each row is normalized to sum to 1.- weights
bool(default:False) If
True, sum the edge weights instead of counting edges.- copy
bool(default:False) If
True, return the interaction matrix instead of storing it.
- adata
- Return type:
- Returns:
If
copy = True, returns the interaction matrix of shape(n_clusters, n_clusters).Otherwise, modifies the
adatawith the following key:anndata.AnnData.uns['{cluster_key}_interactions']- the interaction matrix.