Metadata-Version: 2.4
Name: delnx
Version: 0.3.0
Summary: Differential expression analysis for single-cell genomics
Project-URL: Documentation, https://delnx.readthedocs.io/
Project-URL: Homepage, https://github.com/joschif/delnx
Project-URL: Source, https://github.com/joschif/delnx
Author: Jonas Simon Fleck
Maintainer-email: Jonas Simon Fleck <jonas.simon.fleck@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Jonas Simon Fleck
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.11
Requires-Dist: adjusttext>=1.3
Requires-Dist: anndata>=0.12.0rc3
Requires-Dist: decoupler>=2
Requires-Dist: gseapy>=1.1.9
Requires-Dist: jax>=0.5.3
Requires-Dist: marsilea>=0.5.3
Requires-Dist: numpy>=2.0.2
Requires-Dist: pandas>=2.2.3
Requires-Dist: pydeseq2>=0.5
Requires-Dist: pynndescent>=0.5
Requires-Dist: rich>=14
Requires-Dist: scanpy>=1.11.2
Requires-Dist: scikit-learn>=1.5.1
Requires-Dist: scipy<1.16,>=1.15.3
Requires-Dist: session-info2>=0.1.2
Requires-Dist: statsmodels>=0.14.4
Requires-Dist: tqdm>=4.67.1
Provides-Extra: dev
Requires-Dist: hatch>=1.14.1; extra == 'dev'
Requires-Dist: myst-nb; extra == 'dev'
Requires-Dist: pre-commit>=4.2; extra == 'dev'
Requires-Dist: tox>=4; extra == 'dev'
Requires-Dist: twine>=4.0.2; extra == 'dev'
Provides-Extra: docs
Requires-Dist: docutils!=0.18.*,!=0.19.*,>=0.8; extra == 'docs'
Requires-Dist: furo; extra == 'docs'
Requires-Dist: ipykernel; extra == 'docs'
Requires-Dist: ipython; extra == 'docs'
Requires-Dist: jax; extra == 'docs'
Requires-Dist: myst-nb>=1.1; extra == 'docs'
Requires-Dist: pandas; extra == 'docs'
Requires-Dist: scvi-tools; extra == 'docs'
Requires-Dist: setuptools; extra == 'docs'
Requires-Dist: sphinx-autodoc-typehints; extra == 'docs'
Requires-Dist: sphinx-book-theme>=1; extra == 'docs'
Requires-Dist: sphinx-copybutton; extra == 'docs'
Requires-Dist: sphinx-design; extra == 'docs'
Requires-Dist: sphinx-tippy; extra == 'docs'
Requires-Dist: sphinx>=8; extra == 'docs'
Requires-Dist: sphinxcontrib-bibtex; extra == 'docs'
Requires-Dist: sphinxcontrib-bibtex>=2; extra == 'docs'
Requires-Dist: sphinxext-opengraph; extra == 'docs'
Requires-Dist: statsmodels; extra == 'docs'
Requires-Dist: tox>=4; extra == 'docs'
Requires-Dist: twine>=4.0.2; extra == 'docs'
Provides-Extra: test
Requires-Dist: coverage[toml]>=7; extra == 'test'
Requires-Dist: hatch>=1.14.1; extra == 'test'
Requires-Dist: pytest-cov>=6.1; extra == 'test'
Requires-Dist: pytest-mock>=3.14; extra == 'test'
Requires-Dist: pytest>=8.3.5; extra == 'test'
Description-Content-Type: text/markdown

<img src="docs/_static/images/delnx.png" width="300" alt="delnx">


[![PyPI version][badge-pypi]][pypi]
[![Tests][badge-tests]][tests]
[![Codecov][badge-coverage]][codecov]
[![pre-commit.ci status][badge-pre-commit]][pre-commit.ci]
[![Documentation Status][badge-docs]][documentation]


[badge-tests]: https://github.com/joschif/delnx/actions/workflows/test.yaml/badge.svg
[badge-docs]: https://img.shields.io/readthedocs/delnx
[badge-coverage]: https://codecov.io/gh/joschif/delnx/branch/main/graph/badge.svg
[badge-pre-commit]: https://results.pre-commit.ci/badge/github/joschif/delnx/main.svg
[badge-pypi]: https://img.shields.io/pypi/v/delnx.svg?color=blue


# 🌸 delnx

**delnx** (`"de-lo-nix"  | /dɪˈlɒnɪks/`) is a python package for differential expression analysis of (single-cell) genomics data. It enables scalable analyses of atlas-level datasets through GPU-accelerated regression models and statistical tests implemented in [JAX](https://docs.jax.dev/en/latest/).

## 🚀 Installation

### PyPI

```
pip install delnx
```

### Development version

```bash
pip install git+https://github.com/joschif/delnx.git@main
```


## ⚡ Quickstart

### Negative binomial DE (count data)

```python
import delnx as dx

# Fit negative binomial GLMs with quasi-likelihood dispersion shrinkage
fit = dx.tl.nb_fit(adata, condition_key="treatment", reference="control")

# Test for differential expression
results = dx.tl.nb_test(adata, fit, contrast="treatment[T.drugA]")
```

### General-purpose DE (log-normalized / binary data)

```python
# Logistic regression with likelihood ratio test
results = dx.tl.de(
    adata,
    condition_key="treatment",
    reference="control",
    contrast="treatment[T.drugA]",
)

# Formula-based design with covariates
results = dx.tl.de(
    adata,
    formula="~ treatment + batch",
    contrast="treatment[T.drugA]",
    method="anova",
)
```

### Per-group DE with grouped wrapper

```python
results = dx.tl.grouped(
    dx.tl.de, adata,
    group_key="cell_type",
    condition_key="treatment",
    reference="control",
    contrast="treatment[T.drugA]",
)
```

### Fast rank-based markers

```python
results = dx.tl.rank_de(adata, condition_key="cell_type")
```

## 💎 Features
- **Negative binomial GLMs**: GPU-accelerated glmGamPoi-style fitting with quasi-likelihood dispersion shrinkage for count data.
- **General-purpose DE**: Logistic regression, ANOVA, and binomial GLM for log-normalized, scaled, or binary data.
- **Formula interface**: R-style formulas (`~ treatment + batch`) parsed by patsy, with treatment coding and reference levels.
- **Rank-based markers**: Fast AUROC-based one-vs-all marker detection with Numba-optimized ranking.
- **Pseudobulking**: Perform DE on large multi-sample datasets by using pseudobulk aggregation.
- **Effect sizes**: Log2 fold change and AUROC computation for pairwise condition comparisons.
- **GPU acceleration**: Core methods are implemented in JAX, enabling GPU acceleration for scalable DE analysis on large datasets.


## 📖 Documentation

For more information, check out the [documentation][documentation] and the [API reference][api documentation].



[issue tracker]: https://github.com/joschif/delnx/issues
[tests]: https://github.com/joschif/delnx/actions/workflows/test.yaml
[documentation]: https://delnx.readthedocs.io
[changelog]: https://delnx.readthedocs.io/en/latest/changelog.html
[api documentation]: https://delnx.readthedocs.io/en/latest/api.html
[pypi]: https://pypi.org/project/delnx
[codecov]: https://codecov.io/gh/joschif/delnx
[pre-commit.ci]: https://results.pre-commit.ci/latest/github/joschif/delnx/main
