Core#

The deepspatial.core module serves as the primary entry point for the DeepSpatial framework. It provides a user-friendly, high-level API designed to facilitate the seamless reconstruction of continuous 3D tissue volumes from discrete 2D spatial transcriptomics slices.

Main Class#

DeepSpatial is the primary user-facing class. It orchestrates internal dataset states, model weights, and the mapping statistics required for physical coordinate space transformations.

DeepSpatial

DeepSpatial: Reconstructing True 3D Spatial Omics at Single-Cell Resolution.

Workflow Methods#

The following methods define the standard workflow for 3D volume reconstruction utilizing the DeepSpatial class:

Data Preparation#

Prior to modeling, the data pipeline must be initialized. This process automatically extracts the physical coordinate boundaries from the 2D slices and computes the normalization statistics necessary for accurate physical dimension scaling.

DeepSpatial.setup_data

Prepares the data pipeline and calculates physical normalization statistics.

Model & Training#

Configures the core Transformer-based architecture and Flow Matching dynamics, while managing the training lifecycle and model checkpoints.

DeepSpatial.build_model

Instantiates the GiT network architecture and Flow Matching logic.

DeepSpatial.fit

Executes the training loop using PyTorch Lightning.

DeepSpatial.load_checkpoint

Loads model weights and metadata for inference or resuming.

3D Reconstruction#

The core generation and inference API. By leveraging the trained continuous vector field, these methods synthesize single-cell resolution gene expression profiles and spatial coordinates within the unobserved physical space between adjacent slices.

DeepSpatial.reconstruct_full_volume

High-level API to reconstruct the entire 3D volume from a list of slices.

DeepSpatial.reconstruct_between_slices

Generates a 3D volume segment between two specific AnnData slices.