hv-anndata

import holoviews as hv
import panel as pn
import scanpy as sc

import hv_anndata
from hv_anndata import A
hv_anndata.register()
hv.extension("bokeh")

Example workflow 1

adata = sc.datasets.paul15()
sc.pp.pca(adata)
sc.pp.neighbors(adata)
sc.tl.umap(adata)
adata
/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)
AnnData object with n_obs × n_vars = 2730 × 3451
    obs: 'paul15_clusters'
    uns: 'iroot', 'pca', 'neighbors', 'umap'
    obsm: 'X_pca', 'X_umap'
    varm: 'PCs'
    obsp: 'distances', 'connectivities'
    layers: None (.X)

Simple HoloViews/Bokeh scatter of UMAP results

(
    hv
    .Scatter(
        adata, A.obsm["X_umap"][0], [A.obsm["X_umap"][1], A.obs["paul15_clusters"]]
    )
    .opts(
        color=A.obs["paul15_clusters"],
        cmap="Category20",
        legend_position="left",
        frame_width=500,
        height=500,
        alpha=0.5,
        tools=["hover"],
    )
    .hist()
)

ManifoldMap App to explore all dimensionality reduction results

hv_anndata.ManifoldMap(
    adata=adata, datashade=False, reduction="X_umap", show_labels=True
)

Holoviews/Bokeh Dotmap plot

ManifoldMap App to explore all dimensionality reduction results

hv_anndata.ManifoldMap(
    adata=adata, datashade=False, reduction="X_umap", show_labels=True
)

Holoviews/Bokeh Dotmap widget

# Required for the GeneSelector to render properly
pn.extension("jsoneditor")
marker_genes = {
    "Erythroids": ["Gata1", "Klf1", "Epor", "Gypa", "Hba-a2"],
    # "Neutrophils": ["Elane", "Cebpe", "Ctsg", "Mpo", "Gfi1"],
    "Monocytes": ["Irf8", "Csf1r", "Ctsg", "Mpo"],
    "Megakaryocytes": ["Itga2b", "Pbx1", "Sdpr", "Vwf"],
    "Basophils": ["Mcpt8", "Prss34"],
    "Mast cells": ["Cma1", "Gzmb"],
}
hv_anndata.Dotmap(adata=adata, marker_genes=marker_genes, groupby="paul15_clusters")

Example workflow 2

Dotmap plot with dendrogram

adata2 = sc.datasets.pbmc68k_reduced()
sel_marker_genes = {
    "CD14+ Mono": ["FCN1"],
    "CD16+ Mono": ["FCGR3A"],
    "ID2-hi myeloid prog": ["ID2", "S100A9"],
    "cDC2": ["CST3", "LYZ", "CLEC10A", "FCER1A"],
    "Lymph prog": ["CD79B", "IGLL1"],
    "B1 B": ["MS4A1", "BLK"],
    "Plasma cells": ["MZB1"],
    "CD4+ T activated": ["CD4", "IL7R"],
    "pDC": ["GZMB"],
}

hv_anndata.Dotmap(
    adata=adata2,
    marker_genes=sel_marker_genes,
    groupby="bulk_labels",
    dendrogram=True,
)

Example workflow 3

Linked brushing enabled between the Manifoldmap and the Dotmap plots

ls = hv.link_selections.instance()

mm = hv_anndata.ManifoldMap(
    adata=adata, reduction="X_umap", show_labels=True, responsive=True, ls=ls
)

marker_genes = {
    "Erythroids": ["Gata1", "Klf1", "Epor", "Gypa", "Hba-a2"],
    "Neutrophils": ["Elane", "Cebpe", "Ctsg", "Mpo", "Gfi1"],
    "Monocytes": ["Irf8", "Csf1r", "Ctsg", "Mpo"],
    "Megakaryocytes": ["Itga2b", "Pbx1", "Sdpr", "Vwf"],
    "Basophils": ["Mcpt8", "Prss34"],
    "Mast cells": ["Cma1", "Gzmb"],
}

dmop = hv_anndata.dotmap_from_manifoldmap(
    mm,
    marker_genes=marker_genes,
    groupby="paul15_clusters",
    plot_opts=dict(height=500),
)

pn.Column(mm, dmop)