Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

Liora: Lorentz Interpretable ODE-Regularized Attention-based VAE

This project has moved to laior. Liora is now developed and released as LAIOR: install it with pip install laior and import it as laior (source: https://github.com/PeterPonyu/Liora). The liora package will not be updated again. This final release, 0.4.4, only adds this notice; its code is identical to 0.4.3.

A deep learning framework for single-cell RNA-seq analysis combining geometric manifold learning, latent dynamics, and comprehensive interpretability.

License: MIT Python 3.9+ PyPI

Liora is a PyTorch-based variational autoencoder (VAE) for single-cell RNA-seq (AnnData) that learns low-dimensional embeddings from raw count matrices using count-likelihood objectives (NB/ZINB/Poisson/ZIP). It integrates (1) Lorentz/hyperbolic manifold regularization for hierarchical structure, (2) latent Neural ODE dynamics for continuous trajectory inference, and (3) an extensive interpretability suite for gene-to-latent attribution.

Key Features

  • Advanced VAE Architecture: Dimensionality reduction with count-based likelihoods (NB, ZINB, Poisson, ZIP)
  • Geometric Manifold Learning: Lorentz (hyperbolic) or Euclidean regularization for hierarchical structure
  • Neural ODE Trajectories: Latent dynamics solved with torchdiffeq (CPU by design). Supports ODE function types legacy, time_mlp (time-conditioned), and gru.
  • Comprehensive Interpretability: Attribution analysis for Genes → Latents (discriminative) and Latents → Genes (reconstructive) pathways.
  • Flexible Encoders: Standard MLP or Transformer-based with self-attention for capturing complex feature dependencies.
  • Information Bottleneck: Hierarchical representation with controllable compression via the i_dim parameter.

Data Requirements

  • adata.layers[layer] must contain raw, non-negative integer-like counts (UMI counts).
    Liora checks this heuristically and raises a ValueError if the layer looks normalized/log-transformed.
  • Liora applies its own log1p + clipping / adaptive normalization internally for training.

Installation

pip install liora

Or install from source:

git clone https://github.com/PeterPonyu/Liora.git
cd Liora
pip install -e .

Quick Start

Basic Usage

import scanpy as sc
from liora import Liora

# Load your data
adata = sc.read_h5ad('data.h5ad')

# Train with default settings
model = Liora(
    adata,
    layer='counts',
    hidden_dim=128,
    latent_dim=10,
    i_dim=2,
)
model.fit(epochs=100)

# Extract embeddings
latent = model.get_latent()

Advanced Configuration

# Transformer encoder + Neural ODE trajectory inference
model = Liora(
    adata,
    layer='counts',
    hidden_dim=128,
    latent_dim=10,
    i_dim=2,
    # Encoder configuration
    encoder_type='transformer',
    attn_embed_dim=64,
    attn_num_heads=4,
    attn_num_layers=2,
    attn_seq_len=32,
    # ODE configuration
    use_ode=True,
    ode_type='time_mlp',
    ode_time_cond='concat',
    ode_hidden_dim=64,
    ode_solver_method='dopri5',
    ode_rtol=1e-5,
    ode_atol=1e-7,
    # Loss weights
    lorentz=5.0,
    beta=1.0,
)
model.fit(epochs=200, patience=20)

# Extract results
latent = model.get_latent()           # Latent embeddings
bottleneck = model.get_bottleneck()   # Information bottleneck
pseudotime = model.get_time()         # Predicted pseudotime
transitions = model.get_transition()  # Transition matrix

Note: get_time() and get_transition() require use_ode=True.

Configuration Guide

Architecture Parameters

Parameter Type Default Description
hidden_dim int 128 Hidden layer dimension
latent_dim int 10 Primary latent space size
i_dim int 2 Information bottleneck dimension

Encoder Options

Parameter Type Default Description
encoder_type str 'mlp' 'mlp' or 'transformer'
attn_embed_dim int 64 Transformer embedding dimension
attn_num_heads int 4 Number of attention heads
attn_num_layers int 2 Transformer encoder layers
attn_seq_len int 32 Token sequence length

ODE Configuration

Parameter Type Default Description
use_ode bool False Enable Neural ODE
ode_type str 'time_mlp' 'legacy', 'time_mlp', or 'gru'
ode_time_cond str 'concat' 'concat', 'film', or 'add'
ode_hidden_dim int None ODE network hidden size
ode_solver_method str 'rk4' Solver: 'rk4', 'dopri5', 'adams', etc.
ode_step_size float None Fixed-step size or 'auto'
ode_rtol float None Relative tolerance (adaptive solvers)
ode_atol float None Absolute tolerance (adaptive solvers)

Loss Configuration

Parameter Type Default Description
recon float 1.0 Reconstruction loss weight
irecon float 0.0 Bottleneck reconstruction weight
lorentz float 0.0 Manifold regularization weight
beta float 1.0 KL divergence weight (β-VAE)
dip float 0.0 DIP-VAE loss weight
tc float 0.0 Total Correlation loss weight
info float 0.0 MMD loss weight
loss_type str 'nb' 'nb', 'zinb', 'poisson', or 'zip'

Training Parameters

Parameter Type Default Description
lr float 1e-4 Learning rate
batch_size int 128 Mini-batch size
train_size float 0.7 Training set proportion
val_size float 0.15 Validation set proportion
test_size float 0.15 Test set proportion

Methods

Training

model.fit(epochs=400, patience=25, val_every=5, early_stop=True)

Extraction

latent = model.get_latent()           # Latent representations
bottleneck = model.get_bottleneck()   # Information bottleneck embeddings
pseudotime = model.get_time()         # Pseudotime (ODE mode)
transitions = model.get_transition()  # Transition probabilities (ODE mode)

Citation

If you use Liora in your research, please cite:

@software{liora2025,
  title = {Liora: Lorentz Information ODE-Regularized Variational Autoencoder},
  author = {Zeyu Fu},
  year = {2025},
  url = {https://github.com/PeterPonyu/Liora}
}

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

Support

Metadata

Release files for liora 0.4.4

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

Source distribution (sdist)

Source distribution for liora 0.4.4
File Size Uploaded Provenance Actions
liora-0.4.4.tar.gz 100.2 kB With provenance Details for liora-0.4.4.tar.gz

Built distribution (wheel)

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

Total release size: 221.4 kB

Release files / liora-0.4.4.tar.gz

Download URL liora-0.4.4.tar.gz
Size 100.2 kB
Tags Source
SHA-256 checksum
How to use checksums
aed1b5305f5181b808fd686b72e9c4c0b1e29fbe75e2da4d5494358b02bc2847
BLAKE2b-256 checksum
How to use checksums
5e6178248eca79659cfc764dc636cd75727a80f3c5c6ed0d273ee5718de1648d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 16, 2026.

Transparency log

Release files / liora-0.4.4-py3-none-any.whl

Download URL liora-0.4.4-py3-none-any.whl
Size 121.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1eb466fb0d15241b6aadabb59b9efe144f7d9e14f8e5bc733dd564981044dfde
BLAKE2b-256 checksum
How to use checksums
1800389c05320dd573ded9f2f405c2db6f316a4ed23121f3620b2931a8284cee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 16, 2026.

Transparency log

Security for liora 0.4.4

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for liora-0.4.4.tar.gz

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 Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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