Skip to main content

Libella

Memory-Optimized Spatial Transcriptomics GNN Pipeline

Libella is an end-to-end Graph Neural Network (GNN) framework designed to discover spatial ecotypes and map topological interfaces across spatial transcriptomics cohorts. By using contiguous spatial batching with $k$-hop preservation, it achieves $O(N)$ compute scalability and $O(1)$ peak memory footprint relative to dataset size. Natively supports NVIDIA CUDA and Apple Silicon (MPS).


Quick Start

Execution is fully CLI-driven via a single .csv manifest file pointing to your .h5ad datasets.

# Standard discovery run
libella manifest.csv --out-dir ./results --mode DISCOVERY

# Fast development test (restricts epochs & cell counts)
libella manifest.csv --out-dir ./results_dev --mode DEV

Installation

Requires Python $\ge$ 3.9.

pip install libella

Data Preparation

Input .h5ad files must feature Human HGNC gene symbols (e.g., CD8A) in adata.var_names.

  • Mouse / Rat Data: Automatically converted to uppercase (e.g., Sox2 $\rightarrow$ SOX2) for cross-species compatibility.
  • Ensembl IDs: Must be converted to HGNC symbols before execution.
import mygene
import scanpy as sc

# Load data
adata = sc.read_h5ad("my_data.h5ad")

# Query Ensembl to HGNC mapping
mg = mygene.MyGeneInfo()
results = mg.querymany(
    adata.var_names, 
    scopes="ensembl.gene", 
    fields="symbol", 
    species="human"
)

# Remap gene symbols
symbol_map = {res["query"]: res.get("symbol", res["query"]) for res in results}
adata.var_names = [symbol_map.get(g, g) for g in adata.var_names]

adata.write_h5ad("my_data_mapped.h5ad")

Manifest Schema

The manifest.csv defines the pipeline execution graph. It requires filepath, discovery, and projection fields.

filepath,dataset_id,patient_id,discovery,projection
/path/to/sample1.h5ad,Dataset_A,Patient_1,True,True
/path/to/sample2.h5ad,Dataset_A,Patient_2,False,True
Flag Value Description
discovery True Computes consensus genes, biological priors, and trains the core GNN.
projection True Projects the trained GNN model onto the sample to extract spatial topology.

Note: Samples marked with discovery=False and projection=True are evaluated as hold-out validation cohorts.


Configuration & Hyperparameters

All pipeline parameters can be overridden at runtime via CLI arguments.

libella manifest.csv \
  --out-dir ./results \
  --epochs 100 \
  --batch-size 15000 \
  --lr-base 0.0005

Core Parameters

Parameter Default Description
--epochs 30 Number of GNN training iterations
--batch-size 10000 Spatial chunk size for memory bounding
--top-n-genes 2000 Number of spatial consensus genes to extract
--k-neighbors 11 Physical graph neighbors constructed per node
--k-hops 2 GNN message-passing neighborhood depth
--dict-temp 0.3 Softmax temperature for spatial dictionary learning
--entropy-pruning True Toggles batch-effect artifact pruning

Run libella -h to inspect the full list of CLI flags.


Output Directory Structure

Executing the pipeline populates --out-dir with the following structure:

results/
├── graphs/
│   └── *.pt                                  # Serialized PyTorch Geometric spatial graphs
├── individual_samples/
│   └── *.csv                                 # Sample-specific topological metrics
└── out/
    ├── final_gnn_model.pt                    # Trained GNN weights checkpoint
    ├── Global_Smoothed_Macro_Domains.parquet # Cell-level spatial domain assignments
    └── Global_Meta_Topology_Continuous_Matrix.csv # Cohort-wide topological matrix

Release files for libella 0.1.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libella 0.1.8.1
File Size Uploaded
libella-0.1.8.1.tar.gz 108.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for libella 0.1.8.1
File Interpreter ABI Platform
libella-0.1.8.1-py3-none-any.whl Python 3 none any Details

Total release size: 224.3 kB

Release files / libella-0.1.8.1.tar.gz

Download URL libella-0.1.8.1.tar.gz
Size 108.6 kB
Tags Source
SHA-256 checksum
How to use checksums
67323f3ffcc21110ebeb5ac7c05e1b23d7578a570627bc9fd444cddf3953d39a
BLAKE2b-256 checksum
How to use checksums
7bef6fc5b5058eb7db0032e6ce051d627e8f850e205a3d13c1d7eacc1de364e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.

Transparency log

Release files / libella-0.1.8.1-py3-none-any.whl

Download URL libella-0.1.8.1-py3-none-any.whl
Size 115.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c723f9a093eaa9101bc542d8ba5a9a3bd522076cb3b1c89ebd591990bd7d8e4
BLAKE2b-256 checksum
How to use checksums
fdfd0566e46805cc7829ccfc94a2902a59348d577f170d8c8ca53f45efe2d64a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.8.1 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page