rapids_singlecell.gr.calculate_niche_cellcharter#
- rapids_singlecell.gr.calculate_niche_cellcharter(adata, *, table_key=None, distance=3, aggregation='mean', random_state=42, spatial_connectivities_key='spatial_connectivities', n_components=10, use_rep=None, min_niche_size=None, mask=None, library_key=None, inplace=True)[source]#
Compute spatial niches with the CellCharter approach on the GPU.
Expression is shell-aggregated over n-hop neighborhoods, PCA-reduced and clustered with a Gaussian mixture. Mirrors
squidpy.gr.calculate_niche_cellcharter[VTSM+24].Labels are written to
adata.obs['cellcharter_niche'].- 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.- distance
int(default:3) Number of n-hop neighborhoods to include.
- aggregation
Literal['mean','variance'] (default:'mean') Per-shell aggregation.
"mean"(default) or"variance".- random_state
int(default:42) Random seed for the GMM.
- spatial_connectivities_key
str(default:'spatial_connectivities') Key in
adata.obspwith the spatial connectivity matrix. Not used whenuse_repis provided.- n_components
int(default:10) Number of mixture components.
- use_rep
str|None(default:None) Key in
adata.obsmto use as the embedding; if provided, the firstn_componentscolumns are used and the shell-aggregation + PCA step is skipped.- 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
Seriesindexed likeadata.obs. Cells that areFalseare labeled"not_a_niche".- library_key
str|None(default:None) Column in
adata.obsidentifying samples. If given, niches are computed per sample and labels are prefixed withlib=<id>_.- inplace
bool(default:True) Write the niche columns to
adata(the selected table for SpatialData). IfFalse, return a modified AnnData copy of that table.
- adata
- Return type: