Python bindings to generate gosling schema.
Project description
ipygosling
Here be dragons 🐉
This is an experimental project that is planned to merge with
gosling.py
. Feedback is much appreciated and most welcomed. Please use with caution.
pip install gosling
Usage
import gosling as gos
data = gos.Data(
url="https://resgen.io/api/v1/tileset_info/?d=UvVPeLHuRDiYA3qwFlm7xQ",
type="multivec",
row="sample",
column="position",
value="peak",
categories=["sample 1"],
binSize=5,
)
track = gos.Track(data=data, layout="linear").mark_bar().encode(
y="peak:Q",
x="start:G",
xe="end:G",
stroke=gos.Channel(value=0.5),
strokeWidth=gos.Channel(value=0.5),
).properties(width=180)
spec = track.view(title="Basic Marks: Bar", subtitle="Tutorial Examples")
print(spec.to_json())
# {
# "subtitle": "Tutorial Examples",
# "title": "Basic Marks: Bar",
# "tracks": [
# {
# "data": {
# "binSize": 5,
# "categories": [
# "sample 1"
# ],
# "column": "position",
# "row": "sample",
# "type": "multivec",
# "url": "https://resgen.io/api/v1/tileset_info/?d=UvVPeLHuRDiYA3qwFlm7xQ",
# "value": "peak"
# },
# "height": 180,
# "layout": "linear",
# "mark": "bar",
# "stroke": {
# "value": 0.5
# },
# "strokeWidth": {
# "value": 0.5
# },
# "width": 180,
# "x": {
# "field": "start",
# "type": "genomic"
# },
# "xe": {
# "field": "end",
# "type": "genomic"
# },
# "y": {
# "field": "peak",
# "type": "quantitative"
# }
# }
# ]
# }
Jupyter notebook
spec # render spec in jupyter cell!
widget = gos.GoslingWidget(spec) # create widget
widget.spec = new_spec # update view
Development
pip install -e .
Generate source code (you should not need to run these steps)
The schema bindings (gosling/schema
) and JS static assets (gosling/static/
)
are automatically generated using the following scripts. Please do not edit these
files directly.
Python schema bindings
python tools/generate_schema_wrapper.py # generates gosling/schema/*
JavScript Jupyter extension/widget
yarn install && yarn build:js # generates gosling/static/{widget.js, index.js}
# Only run this if using gos.GoslingWidget
jupyter nbextension install --py --symlink --overwrite --sys-prefix gosling
jupyter nbextension enable gosling --py --sys-prefix
Add an example
We have started a gallery of community examples in example/
. If you are intereseted in
contributing, please feel free to submit a PR! Checkout the existing examples
for gosling.js if you are looking for inspiration. To add an example, create a .py
file
in example
, and add the new "route" for the website in example/routes.json
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gosling-0.0.1.tar.gz
.
File metadata
- Download URL: gosling-0.0.1.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b02e6f4e00e7cad7b5912ca4304695927434528f049ad93bcdf90c47ceb89349 |
|
MD5 | ab5c60a9302d14844db93abf64996bda |
|
BLAKE2b-256 | 4504b95029d9df0f9e28182f431b5b620e393b631bf54659e2edc13f41897414 |
File details
Details for the file gosling-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: gosling-0.0.1-py3-none-any.whl
- Upload date:
- Size: 1.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f311b34a6a520d9fc8b2fb11ccdde28df16f1cdbd638a832a4c5820c46a9a171 |
|
MD5 | 11c1fa146231e7b78befce47eddc499d |
|
BLAKE2b-256 | 8201997690bab07583a95a358bce5d2c45940c9dedc7e613b2c9322ab443a05a |