{"id":37065620,"url":"https://github.com/gosling-lang/streamlit-gosling","last_synced_at":"2026-01-14T07:41:02.159Z","repository":{"id":44248770,"uuid":"504275510","full_name":"gosling-lang/streamlit-gosling","owner":"gosling-lang","description":"Gosling custom component for Streamlit","archived":false,"fork":false,"pushed_at":"2024-06-07T01:45:02.000Z","size":6061,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-07T23:52:03.911Z","etag":null,"topics":["python","streamlit-component","visualization"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gosling-lang.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-16T19:06:19.000Z","updated_at":"2024-06-07T01:45:05.000Z","dependencies_parsed_at":"2022-07-12T18:19:52.025Z","dependency_job_id":null,"html_url":"https://github.com/gosling-lang/streamlit-gosling","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gosling-lang/streamlit-gosling","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosling-lang%2Fstreamlit-gosling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosling-lang%2Fstreamlit-gosling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosling-lang%2Fstreamlit-gosling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosling-lang%2Fstreamlit-gosling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gosling-lang","download_url":"https://codeload.github.com/gosling-lang/streamlit-gosling/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosling-lang%2Fstreamlit-gosling/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28413470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T05:26:33.345Z","status":"ssl_error","status_checked_at":"2026-01-14T05:21:57.251Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","streamlit-component","visualization"],"created_at":"2026-01-14T07:41:01.466Z","updated_at":"2026-01-14T07:41:02.151Z","avatar_url":"https://github.com/gosling-lang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Streamlit - Gosling\n\nA Streamlit component to display [Genomic Visualization using Gosling](http://gosling-lang.org).\n\n\u003cimg src=\"./assets/demo.gif\"\u003e\n\nAn online demo is host at [Streamlit Clound](https://wangqianwen0418-streamlit-gosling-demo-st-gos-demo-zo60pz.streamlitapp.com/).  \nCheckout the [code of the demo](https://github.com/wangqianwen0418/streamlit-gosling-demo/blob/main/st_gos_demo.py)\n\n\n## Install\n\n```shell script\npip install streamlit gosling streamlit-gosling \n```\n\n\n\n## Usage\n\nThis library provides 2 functions to display gosling visualization :\n\n- `from_gos` to display visualization from a gosling instances. Make sure you have `gosling` installed via `pip install gosling`.\n- `from_json` to display visualization from Golsing spec in the form Python dict.\n\n### using `from_gos`\n```python\n\nimport streamlit as st\nimport gosling as gos\nimport streamlit_gosling as st_gos\n\nsize = 500\n\n\n# create visualization using gosling\n@st.cache_data\ndef chart():\n    data = gos.matrix(\"https://server.gosling-lang.org/api/v1/tileset_info/?d=leung2015-hg38\")\n    return gos.Track(data).mark_bar().encode(\n        x=gos.X(\"xs:G\", axis=\"bottom\"),\n        xe=\"xe:G\",\n        y=gos.Y(\"ys:G\", axis=\"left\"),\n        ye=\"ye:G\",\n        color=gos.Color(\"value:Q\", range=\"hot\", legend=True),\n    ).properties(width=size, height=size).view()\n\n# wrap gosling visualization as a streamlit component\nst_gos.from_gos(\n    spec=chart(), \n    id='id', \n    height=size+ 100\n)\n```\n\n### using `from_json`\n```python\nimport streamlit_gosling as st_gos\n\nspec = {\n  \"title\": \"Basic Marks: bar\",\n  \"subtitle\": \"Tutorial Examples\",\n  \"tracks\": [\n    {\n      \"layout\": \"linear\",\n      \"width\": 800,\n      \"height\": 180,\n      \"data\": {\n        \"url\": \"https://resgen.io/api/v1/tileset_info/?d=UvVPeLHuRDiYA3qwFlm7xQ\",\n        \"type\": \"multivec\",\n        \"row\": \"sample\",\n        \"column\": \"position\",\n        \"value\": \"peak\",\n        \"categories\": [\"sample 1\"],\n        \"binSize\": 5\n      },\n      \"mark\": \"bar\",\n      \"x\": {\"field\": \"start\", \"type\": \"genomic\", \"axis\": \"bottom\"},\n      \"xe\": {\"field\": \"end\", \"type\": \"genomic\"},\n      \"y\": {\"field\": \"peak\", \"type\": \"quantitative\", \"axis\": \"right\"},\n      \"size\": {\"value\": 5}\n    }\n  ]\n}\n\nst_gos.from_gos(\n    spec=spec, \n    id='gos_bar', \n    height= 200\n)\n```\n\n\n- [docs of gosling grammar](http://gosling-lang.org/docs)  \n- [docs of gosling python package](https://gosling-lang.github.io/gos)  \n- [docs of streamlit](https://docs.streamlit.io/)\n\n## API\n\n### streamlit-gosling API\n\n```\nfrom_gos(id: string,\n    spec: a gosling visualization object,\n    height: number,\n    exportButton: boolean,\n    eventType?: 'mouseOver' | 'click' | 'rangeSelect',\n    api?\n)\n```\n\n```\nfrom_json(id: string,\n    spec: a gosling JSON spec as python dicts\n    height: number,\n    exportButton: boolean,\n    eventType?: 'mouseOver' | 'click' | 'rangeSelect',\n    api?\n)\n```\n\n- **id**: `string`\n- **spec**: a visualization object created using Gosling or a gosling JSON spec as python dicts\n- **height**: `number`\n- **exportButton**: `boolean`, whether to include the export button in the gosling component\n- **eventType**: `string`, one of 'mouseOver', 'click', and 'rangeSelect'. If specified, the event data of the specified mouse event will be returned by the streamlit-gosling component.\n- **api**: Call an api function of the gosling visualization. \n  Three types of api actions are currently supported. \n  - `{ action: \"zoomTo\", viewId: string, position: string, padding?: number, duration?: number }`\n  - `{ action: \"zoomToExtent\", viewId: string, duration?: number}`\n  - `{ action: \"zoomToGene\", viewId: string, gene: string, padding?: number, duration?: number }`\n\n  \n\n  example\n  ```python\n  import streamlit as st\n  from streamlit_gosling as st_gos\n\n  # user select a chromosome using streamlit select box\n  chr = st.select('zoom to a chromosome', [str(i) for i in range(1, 20)])\n\n  # the visaulization will zoom to different chromosome based on users' selection above\n  st_gos.from_gos(\n      spec=/****/, \n      id='id', \n      height=350, \n      api={'action': 'zoomTo','viewId': 'track-1', 'position': f'chr{chr}'}\n    )\n  ```\n\n## Development\n\nMake sure `_RELEASE = False` in streamlit_gosling/__init__.py\n\n### Install\n\n- JS side\n\n```shell script\ncd streamlit_gosling/frontend\nnpm install\n```\n\n- Python side\n\n```shell script\nconda create -n streamlit-gosling python=3.9\nconda activate streamlit-gosling\npip install -e .\n```\n\n### Run\n\nYou need to run both the JS side and the Python side for development mode.\n\n- JS side\n\n```shell script\ncd frontend\nnpm run start\n```\n\n- Python side\n\n```shell script\nstreamlit run streamlit_gosling/__init__.py\n```\n\n## Test Before Publish to PYPI\n1. set `_RELEASE = True` in __init__.py\n\n2. check the version number in setup.py\n\n3. run `. publish-script.sh`\n\n4. answer `yes` for uploading to test.pypi for testing. `twine` will prompt you for a username and password. For the username, use `__token__`. For the password, use API token.\n\n5. download and test `pip install --index-url https://test.pypi.org/simple/ --no-deps streamlit-gosling`\n\u003c!-- ## Static HTML file\nIf you only need static rendering of gosling, with no communication from Gosling back to Streamlit, then you may not need `streamlit-gosling`.\nUsing  `components.html` will be the easiest way.\n```python\nimport gosling as gos\nimport streamlit.components.v1\n\nimport urllib.request as urllib\nimport json\n\nURL = \"https://gist.githubusercontent.com/sehilyi/54eaeecd2f07203a707e1516b1cf8e60/raw/d7728224b475a87604f97ba5522e1501edc2565a/gosling.js\"\n\ndef load_schema():\n    with urllib.urlopen(urllib.Request(URL)) as response:\n        raw = response.read()\n        conf = json.loads(raw)\n    return conf\n\nif __name__ == \"__main__\":\n    schema = load_schema()\n    html = gos.View(**schema)._repr_mimebundle_()['text/html']\n    streamlit.components.v1.html(html, width=800, height=300)\n``` --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgosling-lang%2Fstreamlit-gosling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgosling-lang%2Fstreamlit-gosling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgosling-lang%2Fstreamlit-gosling/lists"}