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/numba/cpython/hashing.py:477: UserWarning: FNV hashing is not implemented in Numba. See PEP 456 https://www.python.org/dev/peps/pep-0456/ for rationale over not using FNV. Numba will continue to work, but hashes for built in types will be computed using siphash24. This will permit e.g. dictionaries to continue to behave as expected, however anything relying on the value of the hash opposed to hash as a derived property is likely to not work as expected.
  warnings.warn(msg)