ZOMBI2¶
ZOMBI2 simulates the evolution of species trees, genomes, sequences and traits — each on its own, conditioned on another, or jointly — and records the true history behind every dataset.
The four levels¶
Species, genomes and sequences form a chain of ancestry — a genome lives on the species tree, a sequence inside a gene. Traits are separate: a trait attaches directly to the species tree, so it does not depend on genomes or sequences.
A genome, sequence, or trait always evolves along a species tree. You simulate each level on its own, or let one drive another.
Quickstart¶
Grow a species tree, then evolve gene families along it:
from zombi2 import species, genomes
# a birth–death tree of 20 surviving species
sp = species.simulate_species_tree(birth=1.0, death=0.3, n_extant=20, seed=1)
# gene families along that tree — duplication, transfer, loss, origination
g = genomes.simulate_genomes_family(sp, duplication=0.2, transfer=0.1, loss=0.25,
origination=0.5, initial_families=20, seed=42)
# the genomes you observe are the extant tips, keyed by tip name
observed = g.genomes
ZOMBI2 lets you describe very specific evolutionary scenarios, and rates are how you do it. Every rate is written the same way — a scope, with verbs chained onto it (a rate that changes in time, saturates with diversity, or drifts along the tree):
from zombi2.params import Global, PerLineage
sp = species.simulate_species_tree(
birth = PerLineage(1.0).changing_at({0: 1.0, 3: 0.5}), # skyline: full rate, then half after time 3
death = Global(0.3), # one tree-wide death rate, not per lineage
n_extant = 20, seed = 1) # grow until 20 species survive
For an AI agent¶
An agent that will use ZOMBI2 in your project starts from one file, which installs it and says how it is driven. Give the agent this line:
Fetch and follow the instructions at https://aadavin.github.io/zombi2/docs/agent-setup/prompt.txt to set me up for ZOMBI2.
The same file is linked from llms.txt, the index
language models look for.
Where next¶
- New here? Start with the Introduction, which tours the whole tool in one pass.
- The level guides — each grows one level and the objects a run returns: Species trees, Genomes (with ordered and nucleotide resolutions), Sequences, and Traits.
- Dependent runs — connections that let one level drive another, in ordered runs or in one joint run.
- Reference: the API, the output files each run writes, and the tools that read a finished run.