$\textsf{\textcolor{#0f766e}{Z}OMBI2}$
🌐 Website · Gallery · Documentation · Manual (pdf) · Roadmap
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
pip install zombi2
Quickstart
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 --seed 1
zombi2 sequences out/ --model hky85 --length 1000 --divergence 0.2 --seed 1
From Python, each level is one call, and the result object carries the history:
from zombi2 import species, genomes, sequences
from zombi2.sequences.substitution_models import hky85
sp = species.simulate_species_tree(birth=1.0, death=0.3, n_extant=20, seed=1)
g = genomes.simulate_genomes_family(sp, duplication=0.2, transfer=0.1, loss=0.25, seed=1)
s = sequences.simulate_sequences(g, model=hky85(), length=1000, divergence=0.2, seed=1)
g.gene_trees # the true gene tree of every family
sp.write("out/") # the trees, the event log and the fates
g.write("out/") # gene trees, the event log, profiles
s.write("out/") # alignments and phylograms (ancestral is opt-in)
Each write fills the directory it is given, so these three share out/; the commands above group
the same run into out/species/, out/genomes/ and out/sequences/, and add a log per level and a
run.zombi2 report. The two routes count families differently, too: the Python result holds an
alignment for every family born, empty where no copy survived, while the commands count the
survivors. run.zombi2 gives both, as families 100 born · 92 surviving · 8 died out.
Levels
ZOMBI2 is organized around four levels of evolution. A genome or a trait evolves along the species tree, and a sequence evolves inside a gene of the genome, so a sequences run needs a genomes run first. The levels you run are composed into one seeded, reproducible run.
- 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.
- Genomes — gene families under duplication, transfer, loss and origination, at three resolutions: gene families, ordered chromosomes with rearrangements, and nucleotide genomes, with real DNA along each chromosome.
- Sequences — nucleotide (JC69, K80, HKY85, GTR) and protein substitution models run down each gene tree, with ancestral sequences at every node.
- Traits — continuous traits that diffuse, revert to an optimum or shift at speciation, and discrete traits switching between states.
Dependent runs
Dependent runs are how ZOMBI2
simulates a scenario where one part of the run controls another — a habitat trait that makes
lineages lose genes four times faster in the water, a gene family whose presence speeds up transfer
for the rest of the genome, a GC content that sets how fast a trait changes. Every dependency is
written as a connection, with three parts: the driver, the value that is read; the
target, the parameter that depends on it (a rate, an extent, or which lineage receives a
transfer); and the link between them, which says what each value of the driver is worth and
what that number does to the target (scaled_by).
When the driver can be simulated first, the run is conditioned: two ordinary runs in order, the second reading the file the first one wrote.
zombi2 species out/ --birth 1 --death 0.3 --n-extant 20 --seed 1
zombi2 traits out/ --kind discrete --states aquatic,terrestrial --switch 0.4 --seed 1
zombi2 genomes out/ --loss "PerCopy(0.25).scaled_by('out/traits/trait_events.tsv', {'aquatic': 4.0})" --seed 1
When neither level can be simulated first, the run is joint: one run simulates both levels at the same time. A trait that speeds up speciation is the standard case — lineages carrying it split more often, so the trait decides the shape of the tree while the tree decides where the trait can go — and the tree comes out as a result rather than going in as an input.
zombi2 joint out/ --birth "PerLineage(1.0).scaled_by('trait', {'small': 1.0, 'large': 3.0})" \
--states small,large --switch 0.3 --n-extant 100 --seed 1
Performance
A species tree of a million leaves takes about six seconds. On the same gene-family task, ZOMBI2 runs about 210× faster than the legacy ZOMBI1 — both pure Python.
The numbers behind the figure are in assets/performance/, one JSON per
benchmark with the raw times and their provenance; the full read is the docs site's
Performance page.
Gallery
The gallery is a page of worked examples, one figure each, with the code that produced it: species trees, genomes, sequences, traits, conditioning and joining. Every figure is drawn with Phylustrator.
Citation
A dedicated ZOMBI2 paper is in preparation. Until then, cite the original ZOMBI.
License
ZOMBI2 is released under the MIT License.
Maintainer, and contributing
ZOMBI2 is maintained and supervised by Adrián Arellano Davín.
Contributions are welcome, from humans and from agents alike — a bug report, a model you wish it could express, a fix, a worked example for the gallery. Start with CONTRIBUTING.md, and open an issue or a pull request.
Metadata
Release files for zombi2 0.51.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| zombi2-0.51.0.tar.gz | 14.8 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| zombi2-0.51.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.5 MB
Release files / zombi2-0.51.0.tar.gz
| Download URL | zombi2-0.51.0.tar.gz |
|---|---|
| Size | 14.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
140a9aa1f48d4ea93a97a3ecfdaa1fe098fa16cb9ee00f1c609bba6fb7a20a68
|
|
BLAKE2b-256 checksum How to use checksums |
2a5543fbbc42193bcded06ac9bb74b6fabe3f9ccd861410984bddfabd5d73cb7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency logRelease files / zombi2-0.51.0-py3-none-any.whl
| Download URL | zombi2-0.51.0-py3-none-any.whl |
|---|---|
| Size | 643.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6cbfcd0ccb1428c191945c6a2b264392126f595823ae502dda0fbc20473d88ff
|
|
BLAKE2b-256 checksum How to use checksums |
0e3b6a88dd019af21ffa169b2206738053b5992eea496a4c2256a3e0551cfc62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency log