Metadata-Version: 2.5
Name: cellina
Version: 1.3.0
Summary: Cellina: Dual-encoder VAE for spatial transcriptomics with adversarial domain forgetting
Project-URL: Documentation, https://github.com/PMBio/cellina
Project-URL: Source, https://github.com/PMBio/cellina
Project-URL: Home-page, https://github.com/PMBio/cellina
Author: Abdul Moeed, Stefan Schrod, Martin Rohbeck, Marc Jan Bonder, Pavlo Lutsik, Oliver Stegle, Daniel Dimitrov
Maintainer-email: Abdul Moeed <abdul.moeed@dkfz-heidelberg.de>, Daniel Dimitrov <daniel.dimitrov@embl.de>
License: BSD 3-Clause License
        
        Copyright (c) 2025, Yosef Lab, Weizmann Institute of Science
        
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: anndata
Requires-Dist: rich
Requires-Dist: scikit-learn
Requires-Dist: scipy
Requires-Dist: scvi-tools>=1.2.0
Requires-Dist: session-info
Requires-Dist: torch>=2.4
Provides-Extra: dev
Requires-Dist: bump2version; extra == 'dev'
Requires-Dist: pre-commit; extra == 'dev'
Requires-Dist: twine>=4.0.2; extra == 'dev'
Provides-Extra: doc
Requires-Dist: ipykernel; extra == 'doc'
Requires-Dist: ipython; extra == 'doc'
Requires-Dist: myst-nb; extra == 'doc'
Requires-Dist: sphinx-autodoc-typehints; extra == 'doc'
Requires-Dist: sphinx-book-theme>=0.3.3; extra == 'doc'
Requires-Dist: sphinx-copybutton; extra == 'doc'
Requires-Dist: sphinx>=4; extra == 'doc'
Requires-Dist: sphinxcontrib-bibtex>=1.0.0; extra == 'doc'
Provides-Extra: gat
Requires-Dist: torch-geometric>=2.6; extra == 'gat'
Requires-Dist: torch-scatter>=2.1; extra == 'gat'
Requires-Dist: torch-sparse>=0.6.18; extra == 'gat'
Provides-Extra: test
Requires-Dist: pytest; extra == 'test'
Requires-Dist: pytest-cov; extra == 'test'
Description-Content-Type: text/markdown

<p align="center"><img src="https://raw.githubusercontent.com/PMBio/cellina/main/docs/banner.svg" alt="Cellina" width="75%"></p>
<!-- docs-readme-start -->

# Cellina

[![Tests](https://github.com/PMBio/cellina/actions/workflows/test.yml/badge.svg)](https://github.com/PMBio/cellina/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/PMBio/cellina/branch/main/graph/badge.svg)](https://codecov.io/gh/PMBio/cellina)
[![Documentation Status](https://readthedocs.org/projects/cellina/badge/?version=latest)](https://cellina.readthedocs.io/en/latest/?badge=latest)
[![arXiv](https://img.shields.io/badge/arXiv-2606.08493-b31b1b)](https://arxiv.org/abs/2606.08493v2)

Cellina predicts how a cell's gene expression would change if its spatial neighborhood changed — *tissue graph counterfactuals*. It disentangles a cell's **intrinsic state** (*z*) from its **spatial context** (*s*), then answers two kinds of query on the tissue graph:

- **Edge perturbation** — swap a cell's neighbors (e.g. give healthy cells a tumor neighborhood).
- **Node perturbation** — change what the neighbors express (e.g. activate or knock out a pathway).

Method details are in the paper: [*Querying Counterfactuals on Tissue Graphs with Supervised Disentanglement*](https://arxiv.org/abs/2606.08493v2) (NeurIPS 2026).

## Models

| Class | Paper name | Spatial encoder |
|---|---|---|
| `Cellina` | *Cellina* | Pseudobulk of neighbor expression → MLP; fast, scales like non-spatial baselines |
| `CellinaGCN` | *Cellina-GAT* | GATv2 on the local subgraph; learns attention over neighbors |

Both perform on par.

## Getting started

Install with one of the shipped conda environments — [`environment.yml`](https://github.com/PMBio/cellina/blob/main/environment.yml) (GPU/CUDA) or [`env_minimal.yml`](https://github.com/PMBio/cellina/blob/main/env_minimal.yml) (CPU) — via `conda env create -f <file>`. Without conda, `pip install cellina` gives `Cellina`; `CellinaGCN` additionally needs PyG: install the `torch-scatter`/`torch-sparse` wheels for your torch/CUDA from [data.pyg.org](https://data.pyg.org/whl/), then `pip install "cellina[gat]"`.

Then follow the tutorials on colorectal cancer tissue: [Cellina](https://cellina.readthedocs.io/en/latest/tutorial.html) and [Cellina-GAT](https://cellina.readthedocs.io/en/latest/tutorial_gat.html) (notebooks in [`docs/`](https://github.com/PMBio/cellina/tree/main/docs)). Release notes are in the [changelog](https://github.com/PMBio/cellina/blob/main/CHANGELOG.md).

## Citation

```bibtex
@inproceedings{moeed2026querying,
  title     = {Querying Counterfactuals on Tissue Graphs with Supervised Disentanglement},
  author    = {Moeed, Abdul and Schrod, Stefan and Rohbeck, Martin and Bonder, Marc Jan and Lutsik, Pavlo and Stegle, Oliver and Dimitrov, Daniel},
  booktitle = {The Fortieth Annual Conference on Neural Information Processing Systems},
  year      = {2026},
  url       = {https://arxiv.org/abs/2606.08493v2}
}
```

Built on [scvi-tools](https://scvi-tools.org). Bugs and questions: [issue tracker](https://github.com/PMBio/cellina/issues).
