Metadata-Version: 2.4
Name: scbulkde
Version: 0.0.2
Summary: Performing differential testing on pseudobulked single-cell data
Project-URL: Documentation, https://scBulkDE.readthedocs.io/
Project-URL: Homepage, https://github.com/quadbio/scBulkDE
Project-URL: Source, https://github.com/quadbio/scBulkDE
Author: Adnan Abouelela
Maintainer-email: Adnan Abouelela <adnan.abouelela@bsse.ethz.ch>
License: BSD 3-Clause License
        
        Copyright (c) 2025, Adnan Abouelela
        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
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.11
Requires-Dist: anndata
Requires-Dist: formulaic
Requires-Dist: pydeseq2
Requires-Dist: rich
Requires-Dist: session-info2
Requires-Dist: statsmodels
Requires-Dist: tqdm
Description-Content-Type: text/markdown

# scBulkDE

![Tests][badge-tests]
![Documentation][badge-docs]
![Coverage][badge-coverage]
![PyPI][badge-pypi]

[badge-tests]: https://img.shields.io/github/actions/workflow/status/quadbio/scBulkDE/test.yaml?branch=main
[badge-docs]: https://img.shields.io/readthedocs/scBulkDE
[badge-coverage]: https://codecov.io/gh/quadbio/scbulkde/branch/main/graph/badge.svg
[badge-pypi]: https://img.shields.io/pypi/v/scbulkde.svg

scBulkDE performs differential expression testing on pseudobulked single-cell data. It aggregates cells into pseudobulk samples, infers a full-rank design matrix and performs differential gene expression analysis while accounting for categorical and continuous covariates. Currently PyDeseq2 and ANOVA backends are supported for DE testing.

## Key features

- **Pseudobulk aggregation** with quality control
- **Covariate-aware design** — categorical and continuous covariates with automated resolution of confounding factors
- **Multiple DE engines** — ANOVA F-test and PyDESeq2
- **Fallback strategies** — pseudoreplicate generation or single-cell testing when biological replicates are insufficient
- **Scanpy drop-in** — `tl.rank_genes_groups` stores results in `adata.uns` for seamless integration with scanpy.

## Installation

You need to have Python 3.11 or newer installed on your system.

Install from PyPI:

```bash
pip install scbulkde
```

Or install the latest development version:

```bash
pip install git+https://github.com/quadbio/scBulkDE.git@main
```

## Quick start

```python
import scbulkde as scb

# One-step: pseudobulk + DE
de_result = scb.tl.de(
    adata,
    group_key="cell_type",
    query="B cells",
    reference="rest",
    replicate_key="donor",
    engine="anova",
)

de_result.results.head()
```

Or separate pseudobulking from testing for more control:

```python
# Step 1 — Pseudobulk
pb_result = scb.pp.pseudobulk(
    adata,
    group_key="cell_type",
    query="B cells",
    reference="rest",
    replicate_key="donor",
)

# Step 2 — DE
de_result = scb.tl.de(pb_result, engine="anova")
```

### Scanpy drop-in replacement

```python
import scanpy as sc
import scbulkde as scb

scb.tl.rank_genes_groups(
    adata,
    groupby="cell_type",
    de_kwargs=dict(replicate_key="donor", engine="anova"),
)

sc.pl.rank_genes_groups(adata, n_genes=20)
```

## Documentation

Please refer to the [documentation][], in particular the [API documentation][].

## Release notes

See the [changelog][].

## Contact

For questions and help requests, you can reach out in the [scverse discourse][].
If you found a bug, please use the [issue tracker][].

## Citation

> t.b.a

[uv]: https://github.com/astral-sh/uv
[scverse discourse]: https://discourse.scverse.org/
[issue tracker]: https://github.com/quadbio/scBulkDE/issues
[tests]: https://github.com/quadbio/scBulkDE/actions/workflows/test.yaml
[documentation]: https://scBulkDE.readthedocs.io
[changelog]: https://scBulkDE.readthedocs.io/en/latest/changelog.html
[api documentation]: https://scBulkDE.readthedocs.io/en/latest/api.html
[pypi]: https://pypi.org/project/scBulkDE
