squidpy.gr.co_occurrence
- squidpy.gr.co_occurrence(adata, cluster_key, spatial_key='spatial', interval=50, copy=False, n_splits=None, n_jobs=None, backend='loky', show_progress_bar=True)[source]
Compute co-occurrence probability of clusters.
- Parameters:
adata (
AnnData
|SpatialData
) – Annotated data object.cluster_key (
str
) – Key inanndata.AnnData.obs
where clustering is stored.spatial_key (
str
) – Key inanndata.AnnData.obsm
where spatial coordinates are stored.interval (
int
|ndarray
[Any
,dtype
[Any
]]) – Distances interval at which co-occurrence is computed. Ifint
, uniformly spaced interval of the given size will be used.copy (
bool
) – IfTrue
, return the result, otherwise save it to theadata
object.n_splits (
Optional
[int
]) – Number of splits in which to divide the spatial coordinates inanndata.AnnData.obsm
['{spatial_key}']
.backend (
str
) – Parallelization backend to use. Seejoblib.Parallel
for available options.show_progress_bar (
bool
) – Whether to show the progress bar or not.
- Return type:
tuple
[ndarray
[Any
,dtype
[Any
]],ndarray
[Any
,dtype
[Any
]]] |None
- Returns:
: If
copy = True
, returns the co-occurrence probability and the distance thresholds intervals.Otherwise, modifies the
adata
with 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
.