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)[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.cluster_key (
str
) – Key inanndata.AnnData.obs
where clustering is stored.score (
Union
[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 (
Optional
[str
]) – Key inanndata.AnnData.obsp
where spatial connectivities are stored. Default is:anndata.AnnData.obsp
['spatial_connectivities']
.copy (
bool
) – IfTrue
, return the result, otherwise save it to theadata
object.backend (
str
) – Parallelization backend to use. Seejoblib.Parallel
for 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 theadata
with the following key:anndata.AnnData.uns
['{cluster_key}_centrality_scores']
- the centrality scores, as mentioned above.