Example notebook
The tour notebook looks at a 24-sequence protein alignment, computes distances and a neighbour-joining tree with nj.rs, and shows a gene model. The interactive version is the notebook exported to HTML: its widgets are the real components, with no Python running behind them.
Open the interactive notebook View on GitHubTo run it yourself, clone the repository and open packages/python/examples/tour.ipynb. Its data
files sit next to it in data/.
pip install react-bio-viz nj_py jupyterlabjupyter lab packages/python/examples/tour.ipynb1. An alignment
Section titled “1. An alignment”read_fasta loads the records and MSA shows them, here with conservation and logo tracks. Pan,
zoom, select and drag labels as in the live examples.
records = read_fasta("data/aux_iaa.fasta")MSA(msa=records, options={"tracks": ["conservation", "logo"]})
2. Distances
Section titled “2. Distances”nj_py takes the same records as MSA. Its distances, under the
LG model for proteins, go into a DistanceMatrix.
distances = distance_matrix(records, substitution_model="Lg")DistanceMatrix(labels=distances["names"], matrix=distances["matrix"])
3. A tree
Section titled “3. A tree”nj builds a neighbour-joining tree with bootstrap support, and parse_newick turns its Newick
output into the tree PhyloTree draws. Drag a node to rotate the tree, or past the top or bottom to
reroot it.
result = nj(records, substitution_model="Lg", n_bootstrap_samples=100)tree = parse_newick(result["newick"])PhyloTree(tree=tree, interactive=True)nj.rs reports support as a count of replicates. The notebook also scales it to the 0–1 values
PhyloTree shades branches by.
4. A gene
Section titled “4. A gene”A GeneModel shows the transcripts, exons and CDSs of a gene.
5. Share it
Section titled “5. Share it”jupyter nbconvert --to html --execute tour.ipynb exports the notebook with its widgets still
interactive.
To link widgets together and respond to them from Python, continue with Linked views.