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.6.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.6-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: genomespy-0.0.6.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.6.tar.gz
Algorithm Hash digest
SHA256 5390ab4f01f816f63f3ccf64686053f529469f4f0f1bff47b4d6d4288b368fa9
MD5 c1f921ff6d20f57e908679c74a15b289
BLAKE2b-256 5bf75530f6d3d3a092e30c04e260f172abf99767700ac8a31e6a488bc4631b8c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: genomespy-0.0.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 da64f032ff17222e72b43c2be6530a80c7f3979ff6faa57a5788865eff939921
MD5 8fd7483d5dba964a3c04b63d9a09bdef
BLAKE2b-256 76c05bcc4fddde7d0e07f8e486f3052f42ad188d549de96c451b233c5ddd6d7a

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