squidpy.gr.nhood_enrichment
- squidpy.gr.nhood_enrichment(adata, cluster_key, library_key=None, connectivity_key=None, n_perms=1000, numba_parallel=False, seed=None, copy=False, n_jobs=None, backend='loky', show_progress_bar=True)[source]
Compute neighborhood enrichment by permutation test.
- Parameters:
adata (
AnnData
|SpatialData
) – Annotated data object.cluster_key (
str
) – Key inanndata.AnnData.obs
where clustering is stored.library_key (
Optional
[str
]) – If multiple library_id, column inanndata.AnnData.obs
which stores mapping betweenlibrary_id
and obs.connectivity_key (
Optional
[str
]) – Key inanndata.AnnData.obsp
where spatial connectivities are stored. Default is:anndata.AnnData.obsp
['spatial_connectivities']
.n_perms (
int
) – Number of permutations for the permutation test.numba_parallel (
bool
) – Whether to usenumba.prange
or not. If None, it is determined automatically. For small datasets or small number of interactions, it’s recommended to set this to False.copy (
bool
) – IfTrue
, return the result, otherwise save it to theadata
object.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 atuple
with the z-score and the enrichment count.Otherwise, modifies the
adata
with the following keys:anndata.AnnData.uns
['{cluster_key}_nhood_enrichment']['zscore']
- the enrichment z-score.anndata.AnnData.uns
['{cluster_key}_nhood_enrichment']['count']
- the enrichment count.