Skip to main content

$\textsf{\textcolor{#0f766e}{Z}OMBI2}$

🌐 Website · Gallery · Documentation · Manual (pdf)

CI PyPI Docs License: MIT Python 3.10+

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 function, 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, a sequence or a trait always evolves along a species tree, so you run whichever you need, composed into one seeded, reproducible run.

One simulated dataset at all four levels: a species tree with its extinct lineages, the gene order of every surviving genome with homologues linked, the alignment behind one gene family, and two traits drifting together

  • 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.

The four levels of evolution ZOMBI2 simulates: the species tree forks into genomes and traits, and sequences continue below genomes

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).

A connection: a habitat trait on the left, an arrow running right to the gene loss rate and carrying a multiplier for each habitat state, and under the driver the two states and how fast lineages switch between them

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.

The three kinds of run: independent, two levels one after the other; conditioned, the second run reading the finished first one; joint, both levels simulated at the same time, drawn with one arrow with two heads

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 ZOMBI v1 — both pure Python.

ZOMBI2 performance overview: (a) species-tree simulation scaling to millions of tips; (b) genome simulation at the family, ordered and nucleotide resolutions; (c) ZOMBI2 about 210 times faster than the legacy ZOMBI v1 on one shared 1,000-tip tree

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zombi2-0.43.1.tar.gz (12.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zombi2-0.43.1-py3-none-any.whl (569.9 kB view details)

Uploaded Python 3

File details

Details for the file zombi2-0.43.1.tar.gz.

File metadata

  • Download URL: zombi2-0.43.1.tar.gz
  • Upload date:
  • Size: 12.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for zombi2-0.43.1.tar.gz
Algorithm Hash digest
SHA256 831fe54689d5fc6bf77b6e4cf3507bf982f67cd822571a9b1eee0ad0f47382a4
MD5 ccdadb2feea05cacaa6b2e20d93e9b4e
BLAKE2b-256 d713ca79825001f207a6d8643cacc28e3e8be2850c141af9b34feaffe361ff3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for zombi2-0.43.1.tar.gz:

Publisher: release.yml on AADavin/zombi2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zombi2-0.43.1-py3-none-any.whl.

File metadata

  • Download URL: zombi2-0.43.1-py3-none-any.whl
  • Upload date:
  • Size: 569.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for zombi2-0.43.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9b6d88dbeeb834dc26d7a9ec8e735ae95a61aa51fa62503c76dcdfdef18a8cca
MD5 ee928dda626f842d8ee415f89cdca7c6
BLAKE2b-256 e3f973e6a2dfeb1a5844094203de49fd441fb58b5ae9cf70598ee8b1489263cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for zombi2-0.43.1-py3-none-any.whl:

Publisher: release.yml on AADavin/zombi2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.44.0

2 files

0.43.2

2 files

This release

0.43.1 This release

2 files

0.43.0

2 files

0.42.2

2 files

0.42.1

2 files

0.42.0

2 files

0.41.0

2 files

0.40.0

2 files

0.39.4

2 files

0.39.3

2 files

0.39.2

2 files

0.39.1

2 files

0.39.0

2 files

0.38.0

2 files

0.37.0

2 files

0.36.0

2 files

0.35.0

2 files

0.34.0

2 files

0.33.1

2 files

0.33.0

2 files

0.32.0

2 files

0.31.0

2 files

0.30.0

2 files

0.29.0

2 files

0.28.0

2 files

0.27.0

2 files

0.26.0

2 files

0.25.0

2 files

0.24.0

2 files

0.23.0

2 files

0.22.0

2 files

0.21.0

2 files

0.20.0

2 files

0.19.0

2 files

0.18.0

2 files

0.17.0

2 files

0.16.0

2 files

0.15.0

2 files

0.14.0

2 files

0.13.0

2 files

0.12.0

2 files

0.11.0

2 files

0.10.0

2 files

0.9.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page