rapids_singlecell.gr.calculate_niche_utag#

rapids_singlecell.gr.calculate_niche_utag(adata, *, table_key=None, resolutions, n_neighbors=15, spatial_connectivities_key='spatial_connectivities', min_niche_size=None, mask=None, library_key=None, inplace=True)[source]#

Compute spatial niches from UTAG-smoothed expression on the GPU.

Expression is propagated over the L1-normalized spatial graph, PCA-reduced and clustered with leiden. Mirrors squidpy.gr.calculate_niche_utag [KRM+22].

Labels are written to adata.obs['utag_niche_res=<res>'].

Parameters:
adata AnnData | SpatialData

Annotated data matrix or a SpatialData object containing the selected table.

table_key str | None (default: None)

Key in SpatialData.tables; required for SpatialData input. All reads and writes use this table; ignored for AnnData input.

resolutions float | Sequence[float]

Resolution(s) for leiden. A label column is written for each value.

n_neighbors int (default: 15)

Neighbors for the post-aggregation kNN graph passed to leiden.

spatial_connectivities_key str (default: 'spatial_connectivities')

Key in adata.obsp with the spatial connectivity matrix.

min_niche_size int | None (default: None)

Discard niches with fewer cells than this; relabel as "not_a_niche".

mask Series | None (default: None)

Boolean Series indexed like adata.obs. Cells that are False are labeled "not_a_niche".

library_key str | None (default: None)

Column in adata.obs identifying samples. If given, niches are computed per sample and labels are prefixed with lib=<id>_.

inplace bool (default: True)

Write the niche columns to adata (the selected table for SpatialData). If False, return a modified AnnData copy of that table.

Return type:

AnnData | None