centrality_scores#
- squidpy.gr.centrality_scores(adata, *, cluster_key, score=None, connectivity_key=None, copy=False, n_jobs=None, show_progress_bar=False, table_key=None)[source]#
Compute centrality scores per cluster or cell type.
Inspired by usage in Gene Regulatory Networks (GRNs) in [Kamimoto et al., 2020].
Changed in version 1.8.4: The scores run on numba threads, and
n_jobs = Nonenow uses allNUMBA_NUM_THREADSthreads instead of one process. Passn_jobs = 1for the old serial default.- Parameters:
- adata
AnnData|SpatialData Annotated data object.
- table_key
str|None(default:None) Key in
spatialdata.SpatialData.tableswhere the table is stored. Required whenadatais aspatialdata.SpatialDataobject and ignored otherwise.- cluster_key
str Key in
anndata.AnnData.obswhere clustering is stored.- score
Literal['degree_centrality','average_clustering','closeness_centrality'] |Sequence[Literal['degree_centrality','average_clustering','closeness_centrality']] |None(default:None) Group centrality measures as described in
networkx.algorithms.centrality[Hagberg et al., 2008]. If None, use all the options below. Valid options are:’closeness_centrality’ - measure of how close the group is to other nodes.
’average_clustering’ - measure of the degree to which nodes cluster together.
’degree_centrality’ - fraction of non-group members connected to group members.
- connectivity_key
str|None(default:None) Key in
anndata.AnnData.obspwhere spatial connectivities are stored. Default is:anndata.AnnData.obsp['spatial_connectivities'].- copy
bool(default:False) If
True, return the result, otherwise save it to theadataobject.- n_jobs
int|None(default:None) Number of parallel threads to use. None and
-1use numba’s default thread count (NUMBA_NUM_THREADS); asking for more threads than that warns and falls back to it, while0and values below-1raise, since scanpy only supportsn_jobs >= -1.- show_progress_bar
bool(default:False) Whether to show the progress bar or not.
- adata
- Returns:
DataFrame|None– Ifcopy = True, returns apandas.DataFrame. Otherwise, modifies theadatawith the following key:anndata.AnnData.uns['{cluster_key}_centrality_scores']- the centrality scores, as mentioned above.