hv_anndata.plotting.scanpy.draw_graph

hv_anndata.plotting.scanpy.draw_graph(adata, kdims, edge_vdim='connectivities', node_vdims=None, *, neighbors_key='neighbors')

Draw a graph.

Parameters:
adata AnnData

Annotated data matrix.

kdims list[AdDim] | MultiAcc

Key dimensions of the graph. Can just be A.obsm[<k>] or A.varm[<k>] to auto-select components.

edge_vdim Literal['distances', 'connectivities'] | GraphAcc, default: 'connectivities'

Edge value dimension. If "distances"/"connectivities", the graph data is retrieved like scanpy.pp.neighbors() stores it: A.uns[neighbors_key][f"{edge_vdim}_key"]. Therefore .opts(edge_color=calculated_edge_vdim) is set by default.

node_vdims AdDim | list[AdDim] | None, default: None

Node value dimensions.

neighbors_key str, default: 'neighbors'

Key in adata.uns where neighbors are stored. Used only if edge_vdim is "distances"/"connectivities".

Return type:

Graph

Returns:

Graph with colored edges.

Examples

import scanpy as sc
import hv_anndata.plotting.scanpy as hv_sc
from hv_anndata import data, register, A

register()

adata = data.pbmc68k_processed()
sc.pp.neighbors(adata)

hv_sc.draw_graph(
    adata, A.obsm["X_umap"], "distances", [A.obs["bulk_labels"]]
).opts(
    node_color=A.obs["bulk_labels"],
    node_cmap="tab10",
    aspect="square",
    show_legend=True,
    legend_position="right",
)
/home/docs/.local/share/hatch/env/virtual/hv-anndata/STk7F69l/docs/lib/python3.13/site-packages/holoviews/element/graphs.py:337: FutureWarning: Probably comparing to a dimension created from `Dimension.name`. This will not be supported in the future, please report as an issue. 
  if self.nodes and dimension in self.nodes.dimensions():