rapids_singlecell.gr.nhood_enrichment#
- rapids_singlecell.gr.nhood_enrichment(adata, cluster_key, *, table_key=None, library_key=None, connectivity_key='spatial_connectivities', n_perms=1000, seed=None, copy=False)[source]#
Compute neighborhood enrichment by permutation test.
Counts the spatial graph edges between every pair of clusters and compares the counts with
n_permsrandom permutations of the cluster labels. All permutations are counted on the GPU in batches. Cells whose cluster label is missing are removed together with their edges.- Parameters:
- adata
AnnData|SpatialData Annotated data matrix or a SpatialData object containing the selected table.
- cluster_key
str Key in
anndata.AnnData.obswith categorical cluster labels.- table_key
str|None(default:None) Key in
SpatialData.tables; required for SpatialData input. Ignored for AnnData input.- library_key
str|None(default:None) Key in
anndata.AnnData.obswith categorical library labels. If given, cluster labels are only permuted within each library.- connectivity_key
str(default:'spatial_connectivities') Key in
anndata.AnnData.obspwith the spatial connectivity graph.- n_perms
int(default:1000) Number of permutations for the permutation test.
- seed
int|None(default:None) Random seed for the permutations.
- copy
bool(default:False) If
True, return the result instead of storing it.
- adata
- Return type:
- Returns:
- If
copy = True, returns aNhoodEnrichmentResult with the z-score and the enrichment count.
Otherwise, modifies the
adatawith 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.
- If