Skip to content

ZOMBI2

Manual (pdf)

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.

The four levels of ZOMBI2

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

Where next