Skip to main content

Python bindings to generate Gosling visualizations

Project description

gos 🦆

License PyPI Python Version tests Binder Open In Colab

gos is a declarative genomics visualization library for Python. It is built on top of the Gosling JSON specification, providing a simplified interface for authoring interactive genomic visualizations.

Installation

The gos API is under active development. Feedback is appreciated and welcomed.

pip install gosling[all]

Documentation

See the Documentation Site for more information.

Example

Gosling visualization
import gosling as gos

data = gos.multivec(
    url="https://server.gosling-lang.org/api/v1/tileset_info/?d=cistrome-multivec",
    row="sample",
    column="position",
    value="peak",
    categories=["sample 1", "sample 2", "sample 3", "sample 4"],
    binSize=5,
)

base_track = gos.Track(data, width=800, height=100)

heatmap = base_track.mark_rect().encode(
    x=gos.X("start:G", axis="top"),
    xe="end:G",
    row=gos.Row("sample:N", legend=True),
    color=gos.Color("peak:Q", legend=True),
)

bars = base_track.mark_bar().encode(
    x=gos.X("position:G", axis="top"),
    y="peak:Q",
    row="sample:N",
    color=gos.Color("sample:N", legend=True),
)

lines = base_track.mark_line().encode(
    x=gos.X("position:G", axis="top"),
    y="peak:Q",
    row="sample:N",
    color=gos.Color("sample:N", legend=True),
)

gos.vertical(heatmap, bars, lines).properties(
    title="Visual Encoding",
    subtitle="Gosling provides diverse visual encoding methods",
    layout="linear",
    centerRadius=0.8,
    xDomain=gos.GenomicDomain(chromosome="1", interval=[1, 3000500]),
)

Example Gallery

We have started a gallery of community examples in gosling/examples/. If you are interested in contributing, please feel free to submit a PR! Checkout the existing JSON examples if you are looking for inspiration.

Development

This project uses uv for development.

Run tests with:

uv run pytest

The schema bindings (gosling/schema/) and docs (doc/user_guide/API.rst) are automatically generated using the following. Please do not edit these files directly.

# generate gosling/schema/*
uv run tools/generate_schema_wrapper.py <tag_name>

Release

git checkout main && git pull
git commit -m "v0.[minor].[patch]"
git tag -a v0.[minor].[patch] -m "v0.[minor].[patch]"
git push --follow-tags

Design & Implementation

gos is inspired by and borrows heavily from Altair both in project philosophy and implementation. The internal Python API is auto-generated from the Gosling specification using code adapted directly from Altair to generate Vega-Lite bindings. This design choice guarantees that visualizations are type-checked in complete concordance with the Gosling specification, and that the Python API remains consistent with the evolving schema over time. Special thanks to Jake Vanderplas and others on schemapi.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gosling-0.2.3.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

gosling-0.2.3-py3-none-any.whl (1.7 MB view details)

Uploaded Python 3

File details

Details for the file gosling-0.2.3.tar.gz.

File metadata

  • Download URL: gosling-0.2.3.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for gosling-0.2.3.tar.gz
Algorithm Hash digest
SHA256 7fceef35f9430390ed94e4d74a6a86b04d9c939cb18c9e0fc23b71cc3b2bb066
MD5 01940b9483c20743738fede048bd314e
BLAKE2b-256 76de5085a5b0846d6a0e5ee71015451dee2dd0131c2d32c5dc6277ca370f435d

See more details on using hashes here.

Provenance

The following attestation bundles were made for gosling-0.2.3.tar.gz:

Publisher: release.yml on gosling-lang/gos

Attestations:

File details

Details for the file gosling-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: gosling-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for gosling-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0b398cc14dc21841685ffcd37c620a766ad0b7e1611aa800392e163a5be9b3f4
MD5 81b1bc448fb70c39bed6a6dc2d2f424c
BLAKE2b-256 c5fb8b570dc88e1f21f372fe795e3057738161e397db4d5a0d1213fe7d4b8833

See more details on using hashes here.

Provenance

The following attestation bundles were made for gosling-0.2.3-py3-none-any.whl:

Publisher: release.yml on gosling-lang/gos

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page