Metadata-Version: 2.4
Name: gahib
Version: 2.0.0
Summary: Graph Attention Hyperbolic Information Bottleneck VAE for single-cell omics analysis
Author: Zeyu Fu
License: MIT
Project-URL: Homepage, https://github.com/PeterPonyu/GAHIB
Project-URL: Repository, https://github.com/PeterPonyu/GAHIB
Project-URL: Paper, https://doi.org/10.3389/fgene.2026.1863100
Keywords: single-cell,VAE,hyperbolic,graph-neural-network,scRNA-seq
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch>=1.12
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: scikit-learn
Requires-Dist: anndata
Requires-Dist: tqdm
Requires-Dist: pandas
Provides-Extra: graph
Requires-Dist: torch-geometric; extra == "graph"
Provides-Extra: scanpy
Requires-Dist: scanpy; extra == "scanpy"
Provides-Extra: scvi
Requires-Dist: scvi-tools; extra == "scvi"
Provides-Extra: viz
Requires-Dist: matplotlib; extra == "viz"
Requires-Dist: seaborn; extra == "viz"
Provides-Extra: all
Requires-Dist: torch-geometric; extra == "all"
Requires-Dist: scanpy; extra == "all"
Requires-Dist: scvi-tools; extra == "all"
Requires-Dist: matplotlib; extra == "all"
Requires-Dist: seaborn; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: scanpy; extra == "dev"
Requires-Dist: matplotlib; extra == "dev"
Requires-Dist: seaborn; extra == "dev"
Dynamic: license-file

<div align="center">
  <a href="https://peterponyu.github.io/">
    <img src="https://peterponyu.github.io/assets/badges/GAHIB.svg" width="64" alt="ZF Lab · GAHIB">
  </a>
</div>

# GAHIB

A PyTorch implementation of a graph-attention variational autoencoder with
an information bottleneck and a Lorentz hyperbolic geometry loss, applied
to single-cell RNA-seq latent representation learning.

## What it does

Given a `scanpy` `AnnData` with raw counts, GAHIB fits a VAE whose encoder
can be an MLP, a Transformer, or a graph neural network (GAT, GCN,
GraphSAGE, ChebConv, TAG, GraphTransformer, ARMA). The latent code is
shaped by three losses:

- a reconstruction term (NB, ZINB, Poisson, or ZIP),
- an information-bottleneck term that compresses the latent into a 2D
  manifold coordinate, and
- a Lorentz-hyperbolic term that anchors the manifold coordinate on the
  hyperboloid so radial distance encodes hierarchy.

Optional SDE and PDE modules are provided for trajectory experiments.

## Install

```bash
pip install gahib
# graph encoders, scanpy and scVI helpers
pip install "gahib[all]"
```

For development, clone the repository and run `pip install -e ".[all]"`.

Python 3.9 or later. Full dependency list in `pyproject.toml`.

## Usage

```python
import scanpy as sc
from gahib import GAHIB

adata = sc.read_h5ad("data/human_cd34_bone_marrow.h5ad")

model = GAHIB(
    adata,
    layer="counts",
    encoder_type="graph",
    graph_type="GAT",
    latent_dim=10,
    i_dim=2,
    irecon=1.0,
    lorentz=5.0,
)

model.fit(epochs=200, patience=30)
Z = model.get_latent()
```

Set `encoder_type="mlp"` (default) for a plain VAE without the graph
encoder.

## Important constraint

The hyperbolic loss depends on the information-bottleneck target. With
`irecon=0`, the bottleneck coordinate is untrained and the Lorentz
distance becomes degenerate. The model enforces this dependency
internally.

## Main outputs

| Call                  | Returns                               |
| --------------------- | ------------------------------------- |
| `model.get_latent()`  | the learned embedding                 |
| `model.get_time()`    | the trajectory time estimate (if SDE) |
| `model.get_centroid()`| per-cluster latent centroids          |

## Experiment runners

The `experiments/` directory contains reproducible runners for the
benchmark and robustness studies. Each runner takes its dataset paths
from `GAHIB_DATASET_DIRS` and writes results to
`GAHIB_results/{study}/`.

## Repository layout

```text
gahib/       package source (core model, metrics, interpretation)
experiments/ benchmark and robustness runners
tests/       pytest suite
```

## Tests

```bash
pytest
```

## Citation

If you use GAHIB, please cite the article:

> Fu Z, Fu J, Wang X, Liu Y, Ran T. GAHIB: graph attention VAE with a hyperbolic information bottleneck for biologically structured single-cell representations. *Frontiers in Genetics*. 2026;17:1863100. https://doi.org/10.3389/fgene.2026.1863100

```bibtex
@article{fu2026gahib,
  author  = {Fu, Zeyu and Fu, Jiawei and Wang, Xiaoxia and Liu, Yiyao and Ran, Tianfei},
  title   = {GAHIB: graph attention VAE with a hyperbolic information bottleneck for biologically structured single-cell representations},
  journal = {Frontiers in Genetics},
  volume  = {17},
  pages   = {1863100},
  year    = {2026},
  doi     = {10.3389/fgene.2026.1863100}
}
```

GitHub's "Cite this repository" button reads the same record from `CITATION.cff`.

## License

MIT. See `LICENSE`.
