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:

import genomespy as gs
import pandas as pd

# Create sample genomic data
data = pd.DataFrame({
    'chromosome': ['chr1', 'chr1', 'chr2'],
    'start': [1000, 2000, 1500],
    'end': [1500, 2500, 2000],
    'value': [1.5, 2.0, 1.8]
})

# Create visualization
vis = gs.GenomeSpy()

# Configure the visualization
vis.mark("rect", tooltip={"content": "data"})
vis.encode(
    x={"chrom": "chromosome", "pos": "start", "type": "locus"},
    x2={"chrom": "chromosome", "pos": "end"},
    y={"field": "value", "type": "quantitative"},
    color={"field": "value", "type": "quantitative"}
)

# Display the visualization
vis.show()

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: genomespy-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 8af5812f38e7457e19fce4ac3f0317638b5800041d80b049ef127ea1efdf7f5a
MD5 ef280a61e66fd2d30d27e9a628e2fabc
BLAKE2b-256 c6eb387760374b02afecc4a87abb3411e7c9358cd429f6a6dd39153eba151b4d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: genomespy-0.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9699c161d4d0cdd1d08ba66fdafce6a29cb3e95774e2f37734ff57125626f009
MD5 4f1b590b97a02660e87750d11ce195b4
BLAKE2b-256 fb2246c4042091e517796381d5b3db723d0b68cbf8724524279fd343cf09ab7b

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