react-bio-viz
Jupyter widgets for biological data visualization: multiple sequence alignments, phylogenetic trees, distance matrices, gene models, genome browser tracks, and BLAST hit distributions.
These are anywidget bindings around the react-bio-viz React components,
so the same visualizations run in a notebook and in a web app.
Install
pip install react-bio-viz
Use
from react_bio_viz import MSA
widget = MSA(msa=[
{"identifier": "seq1", "sequence": "MKTAYIAKQRQISFVK"},
{"identifier": "seq2", "sequence": "MKTAYIAKQRQISFVR"},
])
widget
Every piece of interactive state is an ordinary synced traitlet, so the kernel can both drive and observe it — no bespoke callback API, just traitlets' own idiom:
# Observe: fires whenever the user pans, zooms, or selects in the browser.
widget.observe(lambda change: print(change["new"]), names="viewport")
# Drive: writing the trait moves the view.
widget.viewport = {**widget.viewport, "x0": 0, "x1": 50}
Widgets
| Class | Data prop | Interactive traits |
|---|---|---|
MSA |
msa |
viewport, selection, row_order, panel_sizes |
PhyloTree |
tree |
viewport, selection; leaf_order (read-only) |
DistanceMatrix |
labels, matrix |
viewport, row_order, panel_sizes |
GeneModel |
gene |
viewport |
GenomeBrowser |
tracks, reference_length |
viewport |
BlastHitDistribution |
hits, query_length |
viewport, selection, metric |
viewport is a plain dict — {"x0", "x1", "y0", "y1", "xMin", "xMax", "yMin", "yMax"} — seeded on
construction to show the whole dataset, so it is readable and observable before any interaction.
selection is {"rows", "columns"} for MSA, {"rerootedAt", "rerootPosition", "collapsed", "order"} for PhyloTree and {"selectedHitIds"} for BlastHitDistribution. row_order has the
same shape on MSA and DistanceMatrix, so one can follow the other with a plain observe.
User actions that are events rather than state arrive through callbacks. The widgets never edit their data themselves — apply the change and assign the new data back:
msa = MSA(msa=records)
msa.on_rename_row(lambda row_id, name: ...)
msa.on_remove_rows(lambda row_ids: ...)
msa.on_remove_columns(lambda columns: ...)
tree = PhyloTree(tree=tree_dict, interactive=True)
tree.on_node_click(lambda node: print(node["id"], node["leafNames"]))
tree.on_branch_click(lambda node: ...)
from react_bio_viz import BlastHitDistribution
hits = BlastHitDistribution(hits=blast_rows, query_length=2000)
hits.observe(lambda c: print("selected:", c["new"]["selectedHitIds"]), names="selection")
hits
Naming
Traits are snake_case (idiomatic Python) and map to the React components' camelCase props;
values that are themselves data — viewport keys, selection keys, options keys — keep their
camelCase spelling, since they cross the wire as JSON and are documented by the JavaScript API.
How it works
An anywidget model is structurally already a StoreController, the external-store seam the React
components use for controlled state (model.get / model.set + save_changes / on("change:…")
↔ getValue / setValue / subscribe). So the Jupyter integration is one adapter,
createAnywidgetStoreController, and no component contains any Jupyter-specific code — a
notebook is just another external-store consumer, the same kind of thing as a web app's Zustand
store.
All six widgets share a single bundled ES module, dispatching on an internal _component trait,
so React ships once in the wheel rather than once per widget.
PhyloTree's layout trait is tree_layout (ipywidgets reserves layout for a widget's CSS layout);
PhyloTree(layout="radial") is accepted as a shorthand.
Example notebook
examples/tour.ipynb loads an alignment, computes p-distances and a
neighbour-joining tree in plain Python, and links all three views. Documentation:
https://holmrenser.github.io/react-bio-viz/python/.
Development
pnpm --filter @react-bio-viz/python-widgets build # bundle the widget JavaScript
uv pip install -e ".[dev]"
pytest
The wheel needs src/react_bio_viz/static/widget.js; the hatchling build hook builds it with
Node if it is missing, and skips when it is already there (so installing from an sdist or wheel
needs no Node toolchain).
License
MIT
Metadata
Release files for react-bio-viz 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| react_bio_viz-0.3.0.tar.gz | 161.7 kB | With provenance | Details for react_bio_viz-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| react_bio_viz-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for react_bio_viz-0.3.0-py3-none-any.whl |
Total release size: 323.5 kB
Release files / react_bio_viz-0.3.0.tar.gz
| Download URL | react_bio_viz-0.3.0.tar.gz |
|---|---|
| Size | 161.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8b03532c437d553c22ae89d59568e09734f4522334315c6b3834b067d66a70e
|
|
BLAKE2b-256 checksum How to use checksums |
a535e34c4739266aa6bcbe723654e9b60b3dad9c903f6af537d1f9fd53ee293b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / react_bio_viz-0.3.0-py3-none-any.whl
| Download URL | react_bio_viz-0.3.0-py3-none-any.whl |
|---|---|
| Size | 161.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
39905b4738a9fabf8d5fd1de060e3e6ba17bdfee03add1f012e9a0adab5493f9
|
|
BLAKE2b-256 checksum How to use checksums |
988b4180c17b43242ac1ec63a95285c4cb7cb69d4c5785b13bf111a91bfca2df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logSecurity for react-bio-viz 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for react_bio_viz-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.