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.obswhere clustering is stored.spatial_key (
str) – Key inanndata.AnnData.obsmwhere spatial coordinates are stored.interval (
int|ndarray[tuple[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 theadataobject.n_splits (
int|None) – Number of splits in which to divide the spatial coordinates inanndata.AnnData.obsm['{spatial_key}'].n_jobs (
int|None) – Number of parallel jobs to use. Forbackend="loky", the number of cores used by numba for each job spawned by the backend will be set to 1 in order to overcome the oversubscription issue in case you run numba in your function to parallelize. To set the absolute maximum number of threads in numba for your python program, set the environment variable:NUMBA_NUM_THREADSbefore running the program.backend (
str) – Parallelization backend to use. Seejoblib.Parallelfor available options.show_progress_bar (
bool) – Whether to show the progress bar or not.
- Return type:
tuple[ndarray[tuple[Any,...],dtype[Any]],ndarray[tuple[Any,...],dtype[Any]]] |None- Returns:
If
copy = 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.