interaction_matrix

interaction_matrix#

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

Compute interaction matrix for clusters.

Parameters:
adata AnnData | SpatialData

Annotated data object.

table_key str | None (default: None)

Key in spatialdata.SpatialData.tables where the table is stored. Required when adata is a spatialdata.SpatialData object and ignored otherwise.

cluster_key str

Key in anndata.AnnData.obs where clustering is stored.

connectivity_key str | None (default: None)

Key in anndata.AnnData.obsp where spatial connectivities are stored. Default is: anndata.AnnData.obsp ['spatial_connectivities'].

normalized bool (default: False)

If True, each row is normalized to sum to 1.

copy bool (default: False)

If True, return the result, otherwise save it to the adata object.

weights bool (default: False)

Whether to use edge weights or binarize.

Returns:

NDArray[Any] | None – If copy = True, returns the interaction matrix.

Otherwise, modifies the adata with the following key: