Skip to main content

GenomeSpy for Python logo

genome-spy-python

CI status PyPI version Open brush example in Colab

genome-spy-python is a Python interface for GenomeSpy, a grammar for interactive and scalable genomic visualization. It lets Python users build GenomeSpy specifications with a declarative, fluent API, serialize them to JSON, and display them in Jupyter or Marimo notebooks.

Read the documentation for the getting-started guide, user guide, examples, and API reference.

Altair is the project's main source of inspiration. This codebase follows Altair's approach of combining schema-backed specification objects with a small handwritten Python API for marks, encodings, composition, and rendering. It adapts that model to GenomeSpy's genomics-native grammar: locus scales, genomic data sources, and coordinated genomic views.

The project is under active development. The current focus is the reusable GenomeSpy Core grammar and notebook rendering; GenomeSpy App-specific features will come later.

Installation

The package requires Python 3.11 or newer.

From PyPI:

pip install genome-spy-python

From source:

pip install uv
git clone https://github.com/genome-spy/genome-spy-python.git
cd genome-spy-python
uv sync

For notebook use, install with Arrow support. This includes PyArrow for dataframe transport:

pip install "genome-spy-python[arrow]"

See creating and updating charts in notebooks for supported tables and live updates.

See the getting-started guide for the first example.

Examples

import genome_spy as gs

chart = (
    gs.Chart(
        [
            {"x": 1, "y": 4, "group": "A"},
            {"x": 2, "y": 3, "group": "B"},
            {"x": 3, "y": 5, "group": "A"},
        ]
    )
    .mark_point(size=80)
    .encode(
        x="x:Q",
        y="y:Q",
        color="group:N",
    )
)

chart

GenomeSpy also has locus-scaled axes for genomic coordinates. This small example renders intervals along a region of chromosome 1:

import genome_spy as gs

intervals = [
    {"chrom": "chr1", "start": 100, "end": 220, "name": "gene A"},
    {"chrom": "chr1", "start": 280, "end": 420, "name": "gene B"},
]

chart = (
    gs.Chart(intervals)
    .mark_rect()
    .encode(
        x=gs.Locus("chrom", "start"),
        x2="end:Q",
        y="name:N",
        color="name:N",
    )
)

chart

Charts can be serialized to a portable GenomeSpy specification or standalone HTML:

chart.to_json()
chart.save("intervals.html")

Update data without recreating the chart

For reactive Jupyter or Marimo notebooks, create a widget with an explicitly named dataset and replace that dataset as inputs change. The browser keeps the existing GenomeSpy instance, so view state such as zoom is preserved.

chart = (
    gs.Chart(data={"name": "table"}, datasets={"table": []})
    .mark_point()
    .encode(x="x:Q", y="y:Q")
)
view = chart.widget()

view.set_dataset("table", updated_dataframe)

See creating and updating charts in notebooks for the Marimo pattern.

Contributing

Contributions are welcome. See CONTRIBUTING.md for development setup, testing, code generation, documentation, gallery, and pull-request guidelines.

References

  • GenomeSpy — the upstream visualization grammar and JavaScript renderer.
  • Altair — a schema-wrapper design reference.
  • Gos — a related grammar and Python-wrapper design reference for genomics visualization.

Portions of the schema-wrapper implementation and selected tests are adapted from Altair under its BSD-3-Clause license. See Third-party notices for the exact sources and license.

Release files for genome-spy-python 0.4.0

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

Source distribution (sdist)

Source distribution for genome-spy-python 0.4.0
File Size Uploaded
genome_spy_python-0.4.0.tar.gz 13.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for genome-spy-python 0.4.0
File Interpreter ABI Platform
genome_spy_python-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.3 MB

Release files / genome_spy_python-0.4.0.tar.gz

Download URL genome_spy_python-0.4.0.tar.gz
Size 13.9 MB
Tags Source
SHA-256 checksum
How to use checksums
a56e7f60d5bc4a17dea472199ae6d7c226d71fd6b25b0e0eb9bd335dd9c78460
BLAKE2b-256 checksum
How to use checksums
43b989a4a8d63a796dbb7da8d40eca1254c972ea4e1855f561b09a055136e995
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 18, 2026.

Transparency log

Release files / genome_spy_python-0.4.0-py3-none-any.whl

Download URL genome_spy_python-0.4.0-py3-none-any.whl
Size 5.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
70b1417f66eb9d09bb0309e67ad3d2e356bb61d9c0beeecbb7d421f7da1cc701
BLAKE2b-256 checksum
How to use checksums
62cf930aea6444eab57354ee408a4444ef9f7ae6bfaac7897615b2a6db18b6f4
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 18, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.0

2 release files

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 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