Metadata-Version: 2.4
Name: veryMADpy
Version: 0.1.0
Summary: Explicit MAD quality-control annotation for Python and scverse
Author-email: Thomas Sirchi <thomasirchi@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/Thokas99/veryMADpy
Project-URL: Repository, https://github.com/Thokas99/veryMADpy
Project-URL: Issues, https://github.com/Thokas99/veryMADpy/issues
Project-URL: Changelog, https://github.com/Thokas99/veryMADpy/blob/main/CHANGELOG.md
Project-URL: Documentation, https://thokas99.github.io/veryMADpy/
Project-URL: Citation, https://github.com/Thokas99/veryMADpy/blob/main/CITATION.cff
Keywords: bioinformatics,scanpy,anndata,quality-control,robust-statistics
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: anndata
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Provides-Extra: test-scanpy
Requires-Dist: scanpy; extra == "test-scanpy"
Provides-Extra: plot
Requires-Dist: matplotlib>=3.6; extra == "plot"
Requires-Dist: seaborn>=0.13; extra == "plot"
Dynamic: license-file

# veryMADpy

MAD-based quality control for cell-level metrics in AnnData and pandas, designed for Scanpy workflows.

<p>
  <a href="https://github.com/Thokas99/veryMADpy/actions/workflows/tests.yml"><img src="https://github.com/Thokas99/veryMADpy/actions/workflows/tests.yml/badge.svg" alt="Tests"></a>
  <a href="https://github.com/Thokas99/veryMADpy/releases/latest"><img src="https://img.shields.io/github/v/release/Thokas99/veryMADpy?display_name=tag&sort=semver" alt="Latest GitHub release"></a>
  <a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-%3E%3D3.10-blue.svg" alt="Python 3.10 or later"></a>
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT license"></a>
</p>

## Overview

veryMADpy fits median absolute deviation (MAD) thresholds to existing per-cell QC metrics. It flags potential outliers for review and leaves filtering decisions to the analyst. It reads metrics from `adata.obs`, stores flags there and fit provenance in `adata.uns["verymad"]`, and also supports pandas DataFrames. Scanpy and plotting dependencies are optional.

The default policy applies four scaled MADs to both tails of log-transformed total counts and detected genes, and the upper tail of mitochondrial percentage. Sample-wise fitting, custom metrics and thresholds, filtering, summaries, and diagnostic plots are supported.

## Installation

Install veryMADpy from PyPI:

```bash
python -m pip install veryMADpy
```

Install Scanpy separately to calculate QC metrics. Install the `plot` extra only when using `vm.pl`:

```bash
python -m pip install "veryMADpy[plot]"
```

## Quick start

Given raw counts in `adata.X`, a Boolean mitochondrial annotation in `adata.var["mt"]`, and a `sample_id` column in `adata.obs`:

```python
import scanpy as sc
import verymadpy as vm

sc.pp.calculate_qc_metrics(adata, qc_vars=["mt"], out=False)
vm.pp.flag_mad_outliers(adata, batch_key="sample_id")
adata_filtered = vm.pp.filter(adata)
```

For Scanpy versions whose `calculate_qc_metrics()` does not support `out=False`, use `inplace=True`. Undefined QC classifications raise during filtering by default; review the [guide](https://thokas99.github.io/veryMADpy/guide/quality-control.html) to choose an explicit policy.

## Documentation

Read the [veryMADpy documentation](https://thokas99.github.io/veryMADpy/) for tutorials, generated API reference, methodology, and the four-donor PBMC validation. Source documentation and build instructions are in [`docs/`](docs/).

## Methodological inspiration

These publications motivate MAD-based QC practice; they did not introduce, evaluate, or endorse veryMADpy. Cite the software itself using [`CITATION.cff`](CITATION.cff).

- Lun, A. T. L., McCarthy, D. J., & Marioni, J. C. (2016). A step-by-step workflow for low-level analysis of single-cell RNA-seq data with Bioconductor. *F1000Research*, 5, 2122. [doi:10.12688/f1000research.9501.2](https://doi.org/10.12688/f1000research.9501.2).
- Heumos, L., et al. (2023). Best practices for single-cell analysis across modalities. *Nature Reviews Genetics*, 24, 550–572. [doi:10.1038/s41576-023-00586-w](https://doi.org/10.1038/s41576-023-00586-w).
- [Single-cell Best Practices: Quality control](https://www.sc-best-practices.org/preprocessing-visualization/quality-control/).
- Amezquita, R. A., et al. (2020). Orchestrating single-cell analysis with Bioconductor. *Nature Methods*, 17, 137–145. [doi:10.1038/s41592-019-0654-x](https://doi.org/10.1038/s41592-019-0654-x). See [OSCA quality control](https://bioconductor.org/books/release/OSCA.basic/quality-control.html).

## License

MIT. See [`LICENSE`](LICENSE).
