Metadata-Version: 2.5
Name: compatpower
Version: 0.1.0
Summary: Power, equivalence and design of in vitro compatibility assays between biological control agents and pesticides
Project-URL: Repository, https://github.com/siriani/compatpower
Author: Allan Lincoln Rodrigues Siriani, Susi Meire Maximino Leite
License-Expression: MIT
License-File: LICENSE
Keywords: biological control,compatibility,entomopathogenic fungi,equivalence test,experimental design,pesticides,statistical power
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=2.0
Requires-Dist: scipy>=1.10
Provides-Extra: test
Requires-Dist: pytest>=7; extra == 'test'
Description-Content-Type: text/markdown

# compatpower

[![tests](https://github.com/siriani/compatpower/actions/workflows/tests.yml/badge.svg)](https://github.com/siriani/compatpower/actions/workflows/tests.yml)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24380785.svg)](https://doi.org/10.5281/zenodo.24380785)

**Power, equivalence and design of in vitro compatibility assays between biological control agents and pesticides.**

In vitro compatibility assays (for example, colony-forming units of an entomopathogenic fungus on medium with a pesticide) are often run on a single day with 3–5 plates per treatment. "Compatible" is then declared when the treatment does not differ significantly from the control. `compatpower` simulates such assays to answer three planning questions:

- How likely is my design to detect a given reduction (power)?
- How likely is it to **demonstrate compatibility** with an equivalence test (TOST on the treatment/control ratio)?
- Given a fixed number of plates, how should I split them into independent runs (days) and plates per run?

## Model
Plate counts follow a negative binomial (variance = μ + μ²/k). Each run (day) shifts both groups by a random effect (`sd_run`). The product effect may vary between runs, which is the run × treatment interaction (`tau`). Analyses compared:
- `run`: the run is the experimental unit (paired *t* test on per-run log mean differences). This is recommended and keeps the nominal error rate.
- `pooled`: plates are treated as replicates, as is common practice. Error inflates when `tau > 0`.
- `blocked`: plates with the run as a block, equivalent to a random-run-intercept mixed model.

## Install
```bash
pip install compatpower            # after release
pip install git+https://github.com/siriani/compatpower
```

## Quick start
```python
from compatpower import AssayModel, power, equivalence, design_table, allocate, estimate_model

m = AssayModel(mu0=25, k=4.3, sd_run=0.48, tau=0.15)   # defaults: CFU of a B. bassiana isolate
power(runs=6, plates=10, reduction=0.3, model=m)          # ~0.70
equivalence(runs=8, plates=20, margin=(0.75, 1/0.75), model=m)
allocate(total_plates=60, reduction=0.3, model=m)         # 2x30 vs 10x6 vs 20x3 ...
design_table(model=m)                                     # runs x plates table

import pandas as pd                                      # your own counts: run, group, count [, product]
model, report = estimate_model(pd.read_csv("my_counts.csv"))
```

Command line:
```bash
compatpower power --runs 6 --plates 10 --reduction 0.3
compatpower allocate --total 60
compatpower table --out design.csv
compatpower estimate examples/example_counts.csv
```

## Defaults and caveats
The default parameters are estimated from CFU counts of *Beauveria bassiana* isolate IBCB 170 over three runs. `sd_run` is imprecise (three runs), and `tau` was assumed (0.15), because it can be estimated only when the same product is tested in several runs. Estimate the parameters from your own data whenever possible (`estimate_model`). Analyses use log(count + 0.5). A negative binomial mixed model is the natural alternative for final analyses.

## Citation
Siriani ALR, Leite SMM. compatpower: power, equivalence and design of in vitro compatibility assays between biological control agents and pesticides (version 0.1.0). Zenodo; 2026. https://doi.org/10.5281/zenodo.24380785

Please also cite the accompanying article (in preparation).

## License
MIT
