Skip to main content

PyPI Docs CI

bonsai-rs

Tree representations of single-cell data under Brownian motion. Python bindings for the bonsai-rs crate, a clean-room implementation of Bonsai (de Groot et al., Nature Biotechnology 2026, doi 10.1038/s41587-026-03220-2).

Raw UMI counts in, tree out. Sanity runs first, also in Rust, so the error bars Bonsai needs come from the counts rather than from nowhere.

Install

uv pip install bonsai-rs            # numpy only; dense counts
uv pip install "bonsai-rs[sparse]"  # adds scipy, for sparse counts

Wheels for Python 3.10 and up on Linux x86_64 and macOS.

Use

import bonsai_rs as bs

res = bs.bonsai_from_counts(counts, cell_totals=totals)  # cells x genes

res.tree  # parent array, branch lengths, leaf count
res.node_means  # posterior position of every node, ancestors too
xy = bs.layout(res.tree)  # (n_nodes, 2), edges run node -> parent
newick = bs.to_newick(res.tree, labels=cell_names)

cell_totals is each cell's UMI total over all genes. Leave it out and the row sums are used, which is only right when counts holds every gene.

Already have means and standard deviations? bs.bonsai(means, sds).

Docs

gregorlueg.github.io/bonsai-rs: quickstart, the Sanity handover and its sharp edges, and the API reference.

Development

uv sync
uv run maturin develop --release
uv run pytest
uv run --group docs mkdocs serve

Licence

MIT. Built from the paper and its CC-BY-4.0 Supplementary Information only; see provenance in the repository. Cite the paper.

Release files for bonsai-rs 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for bonsai-rs 0.1.1
File Interpreter ABI Platform
bonsai_rs-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
bonsai_rs-0.1.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
bonsai_rs-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 12.4 MB

Release files / bonsai_rs-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL bonsai_rs-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.4 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
446f90379712ad21c3b0d893635338e85888e07ba1c71587ea93a77924d0d4f5
BLAKE2b-256 checksum
How to use checksums
486fb6fb2e31bd38e84fb478733cb3caaf695ff527c9e93e9d0c24c2f272bbc3
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 Sep 25, 2026.

Transparency log

Release files / bonsai_rs-0.1.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL bonsai_rs-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Size 3.8 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1c625513fce915f4c3ce9b1b9aabb3ae339fff9bce95c79d8516d6500dda53a0
BLAKE2b-256 checksum
How to use checksums
4f6f5321c657a4f5bb9b0c152c3d7036e806075362b3c665620bf1c70f587850
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 Sep 25, 2026.

Transparency log

Release files / bonsai_rs-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL bonsai_rs-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 4.2 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
92ffa6b122f7c6213fb517506a0a86a9209a8ad6da9a6a5cd2d2662c6a4e3217
BLAKE2b-256 checksum
How to use checksums
98727e4d880b5b120920e5c59d638b21dd28bb5fa206aed53aa67dad1bde8b78
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 Sep 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

3 release files

0.1.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page