Metadata-Version: 2.4
Name: zombi2
Version: 0.4.0
Summary: Simulating the evolution of species trees, genomes, sequences and traits
Project-URL: Homepage, https://github.com/AADavin/zombi2
Project-URL: Documentation, https://aadavin.github.io/zombi2/
Project-URL: Repository, https://github.com/AADavin/zombi2
Project-URL: Issues, https://github.com/AADavin/zombi2/issues
Author: Adrián A. Davin
License-Expression: MIT
License-File: LICENSE
Keywords: birth-death,evolution,gene families,phylogenetics,simulation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Requires-Dist: tqdm>=4.60
Provides-Extra: bench
Requires-Dist: matplotlib; extra == 'bench'
Requires-Dist: pyyaml; extra == 'bench'
Requires-Dist: snakemake-executor-plugin-slurm; extra == 'bench'
Requires-Dist: snakemake>=8; extra == 'bench'
Provides-Extra: dev
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: ruff<0.13,>=0.12; extra == 'dev'
Requires-Dist: scipy>=1.10; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material; extra == 'docs'
Requires-Dist: mkdocstrings[python]; extra == 'docs'
Provides-Extra: reconparser
Requires-Dist: pandas>=2.0.0; extra == 'reconparser'
Description-Content-Type: text/markdown

<h1>
  ZOMBI2&nbsp;<img src="assets/logo.svg" alt="ZOMBI2 logo" height="32" align="absmiddle">
</h1>

**[🌐 Website](https://aadavin.github.io/zombi2/)** · [Documentation](https://aadavin.github.io/zombi2/docs/) · [Manual (pdf)](https://aadavin.github.io/zombi2/zombi2-manual.pdf)

[![CI](https://github.com/AADavin/zombi2/actions/workflows/ci.yml/badge.svg)](https://github.com/AADavin/zombi2/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/zombi2)](https://pypi.org/project/zombi2/)
[![Docs](https://img.shields.io/badge/docs-mkdocs--material-blue)](https://aadavin.github.io/zombi2/docs/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue)

**Simulating the evolution of species, genomes, sequences and traits.**

ZOMBI2 simulates evolution at **four levels** — the **species** tree of lineages, the
**genomes** that evolve along it, the **sequences** inside each gene, and the **traits** a
lineage carries. Use it to generate benchmark datasets with known ground truth for phylogenetic and comparative methods.

---

## Install

```bash
pip install zombi2
```

---

## Quickstart

Each level is its own subcommand. Here a dated species tree, then gene families evolving along
it under duplication, transfer, loss and origination, then sequences down each gene tree:

```bash
zombi2 species out/  --birth 1 --death 0.3 --n-extant 20 --seed 1
zombi2 genomes out/ \
                --duplication 0.2 --transfer 0.1 --loss 0.25 --origination 0.5 --seed 42
zombi2 sequences out/ --model hky85 --length 1000 --seed 1
```

`zombi2 <command> -h` documents each of `species`, `genomes`, `sequences` and `traits`, with
its own examples.

From Python, each level is one function, and the result object carries the history:

```python
from zombi2 import species
from zombi2.genomes import simulate_genomes_unordered

sp = species.simulate_species_tree(birth=1.0, death=0.3, n_extant=20, seed=1)
g  = simulate_genomes_unordered(sp, duplication=0.2, transfer=0.1, loss=0.25,
                                origination=0.5, initial_families=20, seed=42)

g.gene_trees                    # the true gene tree of every family
g.write("run/")                 # the event log and the copy-number profiles
```

---

## Levels

ZOMBI2 is organized around **four levels of evolution**. A genome, a sequence or a trait always
evolves along a species tree, so you run whichever you need, composed into one seeded,
reproducible run.

<p align="center">
  <img alt="The four levels of evolution ZOMBI2 simulates: species, genomes and sequences in a chain, with traits branching off species" src="manual/book/figures/fig-2-1-four-levels.svg" width="330">
</p>

- **[Species trees](https://aadavin.github.io/zombi2/docs/guide/species-trees/)** — a
  birth–death process with rates that can shift in time, saturate with diversity or drift down
  the tree, plus mass extinctions, incomplete sampling and fossils. Extinct lineages are kept,
  so the complete tree and the extant one are both available.
- **[Genomes](https://aadavin.github.io/zombi2/docs/guide/genomes/)** — gene families under
  duplication, transfer, loss and origination, at three resolutions: unordered families,
  [ordered](https://aadavin.github.io/zombi2/docs/guide/genomes-ordered/) chromosomes with
  rearrangements, and
  [nucleotide](https://aadavin.github.io/zombi2/docs/guide/genomes-nucleotide/) genomes where
  genes are blocks of DNA.
- **[Sequences](https://aadavin.github.io/zombi2/docs/guide/sequences/)** — nucleotide (JC69,
  K80, HKY85, GTR) and protein substitution models run down each gene tree, with ancestral
  sequences at every node.
- **[Traits](https://aadavin.github.io/zombi2/docs/guide/traits/)** — continuous traits that
  diffuse, revert to an optimum or shift at speciation, and discrete traits switching between
  states.

## Combining levels

A level can be **conditioned** on another — a rate reads a value some other level produced — or
the two can be grown **jointly**, when neither can be simulated first because each drives the
other. Both are one mechanism, `DrivenBy(source, mapping)`, on any rate. See
[conditioning and joining](https://aadavin.github.io/zombi2/docs/guide/conditioning-and-joining/).

---

## Citation

A dedicated ZOMBI2 paper is in preparation. Until then, cite the original
[ZOMBI](https://github.com/AADavin/Zombi).

## License

ZOMBI2 is released under the [MIT License](LICENSE).
