squidpy.gr.interaction_matrix(adata, cluster_key, connectivity_key=None, normalized=False, copy=False, weights=False)[source]

Compute interaction matrix for clusters.

  • adata (AnnData) – Annotated data object.

  • cluster_key (str) – Key in anndata.AnnData.obs where clustering is stored.

  • connectivity_key (Optional[str]) – Key in anndata.AnnData.obsp where spatial connectivities are stored. Default is: anndata.AnnData.obsp ['spatial_connectivities'].

  • normalized (bool) – If True, each row is normalized to sum to 1.

  • copy (bool) – If True, return the result, otherwise save it to the adata object.

  • weights (bool) – Whether to use edge weights or binarize.

Return type

Optional[ndarray[Any, dtype[Any]]]


If copy = True, returns the interaction matrix.

Otherwise, modifies the adata with the following key: