Skip to main content

A python wrapper to the GPU-powered Javascript visualization grammar library GenomeSpy.

Project description

GenomeSpy

PyPI - Version PyPI - Python Version Documentation Status

GenomeSpy is a Python wrapper for the JavaScript visualization grammar library GenomeSpy. It enables the creation of interactive, GPU-accelerated genomic visualizations through a declarative grammar.

GenomeSpy Demo

The Python package provides a high-level interface to create GenomeSpy visualizations. Under the hood, it:

  • Generates JSON specifications that GenomeSpy can interpret
  • Creates a temporary HTTP server to serve local data files
  • Handles rendering in Jupyter notebooks by creating temporary HTML files
  • Supports exporting standalone HTML files for sharing (note: referenced data files must remain accessible)

The javascript (official) version of GenomeSpy is developed in The Systems Biology of Drug Resistance in Cancer group at the University of Helsinki by Kari Lavikka. Original repo is at genome-spy/genome-spy.

Note: This package has been primarily tested with the hg38 (GRCh38) human genome assembly. While it may work with other assemblies, full compatibility is not guaranteed. PRs are welcomed!

Features

  • 🚀 GPU-accelerated rendering for fluid interaction with large datasets
  • 🧬 Native support for genomic data formats including BigWig, BigBed, and Indexed FASTA
  • 📊 Declarative visualization grammar for mapping data to visual channels
  • 🔍 Interactive zooming and navigation for exploring genomic regions
  • 📱 Responsive design that adapts to different screen sizes
  • 🔧 Highly customizable with extensive configuration options

Installation

pip install genomespy

Quick Start

Here's a simple example to get you started:

from genomespy import igv

tracks = {
    "ZBTB7A": {
        "url": "https://chip-atlas.dbcls.jp/data/hg38/eachData/bw/SRX3161009.bw",
        "height": 40,
        "type": "bigwig"
    }}
plot = igv(tracks, region={"chrom": "chr7", "start": 66600000, "end": 66800000}, server_port=18089)
plot.show()

# plot.close() when you finished visualization

Note: When running on a remote server, you'll need to set up port forwarding to access the visualization locally. The default port is 18089, but this can be customized. In VS Code, you can set up port forwarding by:

  1. Opening the "PORTS" tab in the bottom panel
  2. Clicking "Forward a Port"
  3. Entering port 18089 (or your chosen port)

For other IDEs/environments, consult their documentation on port forwarding.

You can also use genomespy with gradio. Check out the example in example_gradio.py.

Documentation

Comprehensive documentation is available at genomespy.readthedocs.io, including:

  • Detailed installation instructions
  • API reference
  • Usage examples
  • Contributing guidelines

Key Concepts

GenomeSpy uses a grammar of graphics approach where visualizations are built by:

  1. Marks: Basic visual elements (rect, point, line, etc.)
  2. Encodings: Mappings from data to visual properties
  3. Scales: Functions that transform data values to visual values
  4. Transforms: Data transformations and calculations
  5. Parameters: Dynamic variables for interaction

Development

To contribute to GenomeSpy:

# Clone the repository
git clone https://github.com/fuxialexander/genomespy.git

# Install development dependencies
cd genomespy
pip install -e ".[dev]"

# Run tests
pytest

License

genomespy is distributed under the terms of the MIT license.

Support

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

genomespy-0.0.7.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

genomespy-0.0.7-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file genomespy-0.0.7.tar.gz.

File metadata

  • Download URL: genomespy-0.0.7.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for genomespy-0.0.7.tar.gz
Algorithm Hash digest
SHA256 adb99643288ae959782a021141a0668713d1fb6d31a15feaddd49a3245f759a6
MD5 3967c7842a4b4f1bf8f6fe77ea842125
BLAKE2b-256 9929ad17aeaa5e7688dcced78c4179bb44b2363c934dfdd6b53779b69d34f7f7

See more details on using hashes here.

File details

Details for the file genomespy-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: genomespy-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for genomespy-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d0bc5200ca0f54f04c7090b26e3d6f49e55cad5dcb3232c13cc35f554e73073e
MD5 3a428102e1ef5a90805a36996b4e46e4
BLAKE2b-256 d6573047b4984c1ff56c84505d79ddf19344cd999f473f38e346c9fe2ce46877

See more details on using hashes here.

Supported by

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