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 in anndata.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 in anndata.AnnData.obsp where spatial connectivities are stored. Default is: anndata.AnnData.obsp ['spatial_connectivities'].

  • copy (bool) – If True, return the result, otherwise save it to the adata object.

  • n_jobs (Optional[int]) – Number of parallel jobs.

  • backend (str) – Parallelization backend to use. See joblib.Parallel for available options.

  • show_progress_bar (bool) – Whether to show the progress bar or not.

Return type:

Optional[DataFrame]

Returns:

: If copy = True, returns a pandas.DataFrame. Otherwise, modifies the adata with the following key:

  • anndata.AnnData.uns ['{cluster_key}_centrality_scores'] - the centrality scores, as mentioned above.