Skip to main content

Python bindings to generate Gosling schema.

Project description

gos 🦆

License PyPI Python Version tests Binder Open In Colab

gos is a declarative (epi)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

Here be dragons 🐉

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

pip install gosling

Documentation

See the Documentation Site for more information.

Example

Gosling visualization
import gosling as gos
from gosling.data import multivec

data = 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.Channel("start:G", axis="top"),
    xe="end:G",
    row=gos.Channel("sample:N", legend=True),
    color=gos.Channel("peak:Q", legend=True),
)

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

lines = base_track.mark_line().encode(
    x=gos.Channel("position:G", axis="top"),
    y="peak:Q",
    row="sample:N",
    color=gos.Channel("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.Domain(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

pip install -e '.[dev]'

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/*
python tools/generate_schema_wrapper.py

Release

git checkout main && git pull

Update version in setup.py and docs/conf.py:

git add setup.py docs/conf.py
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.0.5.tar.gz (11.2 MB view details)

Uploaded Source

Built Distribution

gosling-0.0.5-py3-none-any.whl (63.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gosling-0.0.5.tar.gz
  • Upload date:
  • Size: 11.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for gosling-0.0.5.tar.gz
Algorithm Hash digest
SHA256 99a9e3cad83bd581217264bb800138717618a20a3407b82f5c322e3d448394c0
MD5 a3aef8045618129f1cbdbcc00d946882
BLAKE2b-256 9bce75cf9d55ac25b7e36985d130df09231fb51e83c2410c2aa9b8ee83679847

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gosling-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 63.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for gosling-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 470bc35eff3a21d0b1fab33ae19a4048c327e89edc34f92f4cae99c48b8a311d
MD5 8fa18522c74e67c78359952b2b00f37a
BLAKE2b-256 73909054522b13ce42893e914a5a96f1a80904add5a247c8176984920e39c630

See more details on using hashes here.

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