Skip to main content

3D ST Visualization in Jupyter

Project description

SpatialVista - Interactive 3D Spatial Transcriptomics Visualization in Jupyter

Python Version License Platform Platform

Overview

SpatialVista is an interactive 3D spatial transcriptomics visualization tool designed specifically for Jupyter Notebook/Lab. It seamlessly integrates into your data analysis workflow, providing efficient and intuitive exploration of spatial omics data.

SpatialVista

🌐 Web and App Access

In addition to the Jupyter-based interface, SpatialVista is also available as:

These options allow users to explore 3D spatial transcriptomics data without setting up a Python environment.

Note that the web/app versions support the same core visualization functionalities, while the Jupyter version enables seamless integration with analysis workflows.

✨ Key Features

  • 🚀 High-Performance Rendering - WebGL-based 3D rendering supporting millions of cells
  • 📊 Multi-Dimensional Data Display - Support for categorical annotations, continuous values, gene expression, and more
  • 🎨 Interactive Controls - Real-time adjustment of colors, transparency, point size, and other parameters
  • 🔬 2D/3D View Switching - Flexible switching between 3D point cloud and 2D slice views
  • 🧬 Gene Expression Query - Quick visualization of spatial expression patterns for any gene
  • 📐 Multiple Layout Modes - Support for original coordinates, 2D Treemap, histogram, and more
  • 🎯 Precise Filtering - Filter data points by category, numerical range, and other conditions
  • 💾 One-Click Screenshots - Easily save current views for publications and reports

🎯 Use Cases

SpatialVista is particularly suitable for:

  • Spatial Transcriptomics Data Exploration - Visium, MERFISH, seqFISH, STARmap, and other technologies
  • Single-Cell Spatial Data Analysis - Visualize spatial distribution of cell types
  • Tissue Architecture Studies - Explore molecular features of tissue regions
  • Gene Expression Pattern Analysis - View spatial expression of specific genes
  • Data Quality Control - Quickly check data integrity and outliers

🚀 Quick Start

Dependencies:

  • Python >= 3.10
  • Tested on:
    • macOS 12.0+ (Intel/Apple Silicon)
    • Linux (Ubuntu 18.04+)
    • Windows (windows10/11)
  • Recommended browsers: Chrome or other Chromium-based browsers (with WebGL support).

Installation

pip install spatialvista

Basic Usage

Launch your jupyter notebook or jupyter lab. And play with SpatialVista!

jupyter-lab
import spatialvista as spv
import numpy as np

# Create minimal test data
class FakeAnnData:
    def __init__(self, n: int):
        self.obsm = {"spatial": np.random.rand(n, 3)}
        self.obs = {"celltype": np.random.choice(["A", "B", "C"], n)}
        self.var_names = []
        self.X = None
        self.n_obs = n
adata = FakeAnnData(n=10_000)

# Create visualization
spv.vis(adata, position="spatial", color="celltype")


import scanpy as sc
# Load yout real data
adata = sc.read_h5ad("spatial_data.h5ad")

# Create interactive visualization
spv.vis(
    adata,
    position="spatial",  # obsm key containing spatial coordinates
    color="celltype",    # Default annotation for coloring
    height=600               # Widget height in pixels
)

That's it! 🎉

More demo data for test

  1. Cubic mock data: https://yanglab.westlake.edu.cn/gsmap3d/data/cube.h5ad
  2. Mouse Brain data: https://yanglab.westlake.edu.cn/gsmap3d/data/mouse_brain_3_IQ.h5ad

📚 Core Features

1. Categorical Annotation Visualization

# Color by cell type
widget = spv.vis(
    adata,
    position="spatial",
    color="celltype",
    annotations=["leiden", "tissue_region"]  # Additional annotations to load
)

2. Continuous Value Visualization

# Visualize continuous values (e.g., QC metrics)
widget = spv.vis(
    adata,
    position="spatial",
    color="celltype",
    continuous=["total_counts", "n_genes"]  # Continuous value fields
)

3. Gene Expression Visualization

# View expression patterns of specific genes
widget = spv.vis(
    adata,
    position="spatial",
    color="celltype",
    genes=["Pecam1", "Cd3e", "Epcam"],  # Gene list
    layer="normalized"  # Optional: use specific layer if available
)

4. 2D/3D View Switching

# If data has section information, switch to 2D view in UI
widget = spv.vis(
    adata,
    position="spatial",
    color="celltype",
    section="slice_id",  # Section identifier field for section browser
)

🎨 Interactive Controls

Once displayed, the widget provides rich interactive controls for exploring your data:

  • Navigate in 3D space (rotate, pan, zoom)
  • Switch between annotations and customize colors
  • Query continuous values and gene expression
  • Filter by thresholds and hide specific categories
  • Adjust visualization parameters (size, opacity, layout)
  • Export screenshots

🤝 Contributing & Support

Issues and Pull Requests are welcome!

📄 License

SpatialVista is open-sourced under the MIT License.


Built by WenjieWei@YangLab

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

spatialvista-0.1.2.tar.gz (697.1 kB view details)

Uploaded Source

Built Distribution

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

spatialvista-0.1.2-py3-none-any.whl (704.5 kB view details)

Uploaded Python 3

File details

Details for the file spatialvista-0.1.2.tar.gz.

File metadata

  • Download URL: spatialvista-0.1.2.tar.gz
  • Upload date:
  • Size: 697.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.16

File hashes

Hashes for spatialvista-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ece82e5b539040acfa7165199586a1e8ea53d22134275c31a01cf51a48e2d22a
MD5 33a1ac8199b83d43857668e5661ae90b
BLAKE2b-256 3d5c7ce3b06a1880009cb6219f8729b6f95a13cffdd3ee75e9ad9401606f574e

See more details on using hashes here.

File details

Details for the file spatialvista-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: spatialvista-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 704.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.16

File hashes

Hashes for spatialvista-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6e48895cc8b13fab27435a6d5e78567d079b83f8dab8182ec6c3d8044923f0a2
MD5 b00418328c43bf611cd6642e6d268ca7
BLAKE2b-256 70ed30cd968d54cdd15bac7beec9a04705f16fbdb635705e25004c94ed6482ef

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