co_occurrence#
- squidpy.gr.co_occurrence(adata, *, cluster_key, spatial_key='spatial', interval=50, copy=False, table_key=None)[source]#
Compute co-occurrence probability of clusters.
- Parameters:
- adata
AnnData|SpatialData Annotated data object.
- table_key
str|None(default:None) Key in
spatialdata.SpatialData.tableswhere the table is stored. Required whenadatais aspatialdata.SpatialDataobject and ignored otherwise.- cluster_key
str Key in
anndata.AnnData.obswhere clustering is stored.- spatial_key
str(default:'spatial') Key in
anndata.AnnData.obsmwhere spatial coordinates are stored.- interval
int|NDArray[Any] (default:50) Distances interval at which co-occurrence is computed. If
int, uniformly spaced interval of the given size will be used.- copy
bool(default:False) If
True, return the result, otherwise save it to theadataobject.
- adata
- Returns:
tuple[NDArray[Any],NDArray[Any]] |None– Ifcopy = True, returns the co-occurrence probability and the distance thresholds intervals.Otherwise, modifies the
adatawith the following keys:anndata.AnnData.uns['{cluster_key}_co_occurrence']['occ']- the co-occurrence probabilities across interval thresholds.anndata.AnnData.uns['{cluster_key}_co_occurrence']['interval']- the distance thresholds computed atinterval.