squidpy.gr.centrality_scores
- squidpy.gr.centrality_scores(adata, cluster_key, score=None, connectivity_key=None, copy=False, n_jobs=None, backend='loky', 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].
- Parameters:
adata (
AnnData|SpatialData) – Annotated data object.table_key (
str|None) – Key inspatialdata.SpatialData.tableswhere the table is stored. Required whenadatais aspatialdata.SpatialDataobject and ignored otherwise.cluster_key (
str) – Key inanndata.AnnData.obswhere clustering is stored.score (
str|Iterable[str] |None) –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) – Key inanndata.AnnData.obspwhere spatial connectivities are stored. Default is:anndata.AnnData.obsp['spatial_connectivities'].copy (
bool) – IfTrue, return the result, otherwise save it to theadataobject.n_jobs (
int|None) – Number of parallel jobs to use. Forbackend="loky", the number of cores used by numba for each job spawned by the backend will be set to 1 in order to overcome the oversubscription issue in case you run numba in your function to parallelize. To set the absolute maximum number of threads in numba for your python program, set the environment variable:NUMBA_NUM_THREADSbefore running the program.backend (
str) – Parallelization backend to use. Seejoblib.Parallelfor available options.show_progress_bar (
bool) – Whether to show the progress bar or not.
- Return type:
- Returns:
If
copy = True, returns apandas.DataFrame. Otherwise, modifies theadatawith the following key:anndata.AnnData.uns['{cluster_key}_centrality_scores']- the centrality scores, as mentioned above.