11a A published model as data: stdpopsim orangutans
Status: tested (2026-11-23), sections 1-9. HPC regression passed with 7.0.125 and 6.1.102/6.1.103. All runs were redone with migrate-n 6.1.96 (the slide move of the split times, on by default since 6.1.96 / 7.0.120, changes every result of a split model); sections 4-7 also with 7.0.120, which gives identical results with the same seed.
stdpopsim is a catalogue of published demographic models with their mutation rates and generation times. A data set simulated from one of them is a realistic test: the true values are given in generations, years and numbers of individuals, and the model is not one that Migrate was written for. This recipe takes the two-species orangutan model of Locke et al. (2011), simulates DNA loci with stdpopsim, analyses them with the closest Migrate model (a split with migration and growth), converts the estimates to population sizes, migration rates and years, and compares them with the published values. Read 02-divergence, 03-growth and 10-loci-and-units first.
Contents
- The model
- The data
- The Migrate model and the parmfile
- Results on Migrate’s scale
- Converting to individuals, migrants and years
- Growth or constant size?
- Joint and All
- An unsampled ancestor
- What next
1. The model
stdpopsim PonAbe, model TwoSpecies_2L11 (Locke et al. 2011, Nature
469:529), fitted to the joint site-frequency spectrum of ten Bornean and ten
Sumatran orangutans. Forward in time:
- an ancestral population of 17,934 individuals splits 20,160 generations ago (504,000 years at 25 years per generation);
- after the split, Bornean orangutans shrink slowly from 10,617 to 8,805 individuals today, and Sumatran orangutans grow from 7,317 to 37,661;
- both exchange migrants after the split: each generation a fraction 6.66e-6 of the Bornean population are immigrants from Sumatra, and 1.10e-5 of the Sumatran population are immigrants from Borneo;
- mutation rate 2e-8 per site and generation.
2. The data
scripts/simulate_orangutans.py runs stdpopsim (0.3.0, msprime engine) for
20 independent loci of 5,000 sites with 5 diploid individuals (10 sequences)
per species. Each locus is simulated separately, so the loci are unlinked.
| Data | Recombination within a locus | Segregating sites per locus |
|---|---|---|
data/norec.txt | none (Migrate’s assumption) | 16-41 |
data/rec.txt | stdpopsim’s mean rate for PonAbe, 6.4e-9 per site and generation | 11-60 |
The two files are separate simulations (different genealogies), not the same
genealogies with and without recombination. data/truth.json holds the
model values and their versions on Migrate’s scale.
stdpopsim simulates with the Jukes-Cantor model, so the parmfiles use
datamodel=JC69.
3. The Migrate model and the parmfile
Population 1 is Bornean, population 2 Sumatran. In Migrate’s split model one population continues the ancestral lineage: backward in time (lineage view), the Sumatran lineages move into population 1 at the split time. The model has
- Theta and exponential growth for each population (03-growth);
- migration in both directions after the split;
- a split time D with a spread S (02-divergence).
custom-migration={** D*}
population-growth={1 2}
divergence-distrib=N
bayes-priors= THETA * * UNIFORMPRIOR: 0.0 0.01 0.001
bayes-priors= MIG * * UNIFORMPRIOR: 0.0 2000.0 200.0
bayes-priors= SPLIT * * GAMMAPRIOR: 0.0 0.001 0.005 2.0
bayes-priors= SPLITSTD * * EXPPRIOR: 0.0 0.0001 0.0005
bayes-priors= GROWTH * * UNIFORMPRIOR: -2000.0 10000.0 1000.0
long-sample=40000
joint-samples=10000
heating=YES:1:POWER:5
The constant-size model uses population-growth={0} (section 6).
scripts/make_parmfiles.sh writes all four parmfiles (norec/rec x
growth/const).
What Migrate’s model cannot express: stdpopsim’s ancestral population (17,934 individuals) differs from the population that continues it in Migrate, the Bornean population with its own size and growth rate. With the estimated growth (section 4), Migrate’s Bornean population is about 12,000 individuals at the split, two thirds of the true ancestral size.
M_2->1 here is migration from the daughter population into the ancestral
lineage, forward in time. Backward in time a lineage can move into the
Sumatran population only while it exists, that is, up to the split time.
Since 7.0.115/6.1.91 the Joint combination (section 7) handles this; older
versions used All for this model (7.0.x) or combined it wrongly (6.1.x).
joint-samples=10000 keeps up to 10,000 genealogies per locus for the Joint
combination. The default keeps about 900 for this model (it is bounded by
memory, and a split model with growth stores many numbers per genealogy),
which left most Joint estimates flagged (Joint*, median reweighting ESS
32-69). With 10,000 the median reweighting ESS was 91-105.
Run time on 21 MPI processes (one per locus, plus the master) on 2019 nodes of a cluster: 23-34 minutes.
4. Results on Migrate’s scale
Joint medians and 95% intervals. The true values on Migrate’s scale: Theta = 4 Ne u with today’s Ne, M = m / u, g = (growth rate per generation) / u, D = generations x u.
| Parameter | True | rec.txt | norec.txt |
|---|---|---|---|
| Theta_1 (Bornean) | 0.00070 | 0.00073 [0.00051-0.00095] | 0.00076 [0.00053-0.00104] |
| Theta_2 (Sumatran) | 0.00301 | 0.00319 [0.00181-0.00526] | 0.00222 [0.00147-0.00317] |
| M_2->1 (into Bornean) | 333 | 422 [60-917] | 822 [292-1448] |
| M_1->2 (into Sumatran) | 550 | 402 [59-764] | 550 [176-981] |
| g_1 (Bornean) | -464 | -428 [-800 to -104] | 236 [-696 to 4232] |
| g_2 (Sumatran) | 4065 | 4028* [1472-6936] | 2204 [344-4232] |
| D (split) | 0.000403 | 0.00057* [0.00042-0.00078] | 0.00157 [0.00050-0.00256] |
() Joint rows: the reweighting check flags these as noisy (section 7).
Every interval contains the true value except the split times, which are too
old: 0.00057 in rec.txt (the interval just misses 0.00040) and 0.00157 in
norec.txt (a wide interval, 0.00050-0.00256). A possible reason, not checked:
the ancestral population of the model is about 1.5 times as large as the
population that continues it in Migrate (section 3), and a smaller ancestor
coalesces the lineages faster after the split, which the model can
accommodate by placing the split earlier (backward in time: at a greater
age). Section 8 tests this with a separate ancestor.
The Bornean growth rate is negative in the model (the population shrinks
forward in time); rec.txt recovers the sign, norec.txt does not (its
interval covers both signs). With 10 sequences per population, a growth rate
that changes the population size by 20% over half a million years is hard to
see.
Recombination within the 5,000-site loci (a crossover about every 31,000 generations along each lineage of a locus, so several in the genealogy of a locus) did not change the estimates noticeably in these two data sets.
5. Converting to individuals, migrants and years
Migrate’s parameters contain the mutation rate (10-loci-and-units, section
5). With u = 2e-8 per site and generation and 25 years per generation
(rec.txt, Joint medians):
| Quantity | Formula | Estimate | Published |
|---|---|---|---|
| Ne Bornean (today) | Theta_1 / (4u) | 9,100 | 8,805 |
| Ne Sumatran (today) | Theta_2 / (4u) | 39,900 | 37,661 |
| m into Bornean | M_2->1 u | 8.4e-6 | 6.66e-6 |
| m into Sumatran | M_1->2 u | 8.0e-6 | 1.10e-5 |
| 4Nm into Bornean | Theta_1 M_2->1 | 0.31 | 0.23 |
| 4Nm into Sumatran | Theta_2 M_1->2 | 1.28 | 1.66 |
| growth Bornean, per generation | g_1 u | -8.6e-6 | -9.3e-6 |
| growth Sumatran, per generation | g_2 u | 8.1e-5 | 8.1e-5 |
| split, generations ago | D / u | 28,500 | 20,160 |
| split, years ago | D / u x 25 | 710,000 | 504,000 |
The 4Nm values do not need the mutation rate at all: they are products of two estimated parameters. Everything else is only as good as u: a mutation rate that is off by a factor 2 changes every Ne, m, growth rate and time by the same factor 2.
6. Growth or constant size?
Marginal likelihoods (All (joint) row, log units; higher is better):
| Data | Model | TI | BTI | SS |
|---|---|---|---|---|
| norec.txt | growth | -145793.8 | -145728.7 | -145543.8 |
| norec.txt | constant | -145815.6 | -145748.3 | -145559.0 |
| rec.txt | growth | -145992.5 | -145932.5 | -145775.2 |
| rec.txt | constant | -146019.3 | -145957.4 | -145786.0 |
All three estimators prefer growth in both data sets, by 20-25 log units (BTI): the true model wins. The values of the two data sets are not comparable with each other (different data).
7. Joint and All
The All row multiplies the per-locus posteriors parameter by parameter
(00-basics, section 8); the Joint row combines the loci with their
genealogies. For the split time they disagree strongly (rec.txt):
| Parameter | True | Joint | All |
|---|---|---|---|
| D (split) | 0.000403 | 0.00057 [0.00042-0.00078] | 0.00394 [0.00384-0.00401] |
| g_1 (Bornean) | -464 | -428 [-800 to -104] | 7420 [576-9960] |
| Theta_2 (Sumatran) | 0.00301 | 0.00319 [0.00181-0.00526] | 0.00236 [0.00149-0.00371] |
Most single loci say little about the split time (few lineages reach it),
so each locus’ posterior of D is wide and leans toward large values; their
product (All) piles up near the upper end of the prior (0.005). The All
estimate of D is ten times the truth and its interval is very narrow; the
Joint estimate is within a factor 2. The same happens to the Bornean growth
rate. Report the Joint rows; when they carry a star (Joint*), run longer,
add replicates or raise joint-samples rather than fall back to All.
8. An unsampled ancestor
The model of sections 3-7 lets the Bornean population stand in for the ancestor. Migrate can instead add the ancestor as a third population without samples, from which both species split at the same time:
3 20 PonAbe TwoSpecies_2L11 with recombination, unsampled ancestor
... (the two sampled populations as before)
0 Ancestor
custom-migration={**t **t 00*}
population-growth={1 2 0}
The infiles data/norec3.txt and data/rec3.txt are the same data with the
empty third population. t marks tied splits: populations 1 and 2 split from
population 3 with one shared split time (02-divergence); the two
daughters exchange migrants, the ancestor gets its own Theta_3 and no growth.
This is the structure of the stdpopsim model. Migration into either daughter
(backward in time) is possible only up to the split, so both migration rates
are gated (section 3). Parmfiles parmfile.norec-anc and parmfile.rec-anc;
21 MPI processes, 41-47 minutes.
Joint medians and 95% intervals, rec3.txt:
| Parameter | True | three populations | two populations (section 4) |
|---|---|---|---|
| Theta_1 (Bornean) | 0.00070 | 0.00088 [0.00052-0.00134] | 0.00073 [0.00051-0.00095] |
| Theta_2 (Sumatran) | 0.00301 | 0.00365 [0.00195-0.00591] | 0.00319 [0.00181-0.00526] |
| Theta_3 (ancestor) | 0.00143 | 0.00140 [0.00092-0.00193] | - |
| M_2->1 | 333 | 550 [156-1035] | 422 [60-917] |
| M_1->2 | 550 | 259 [23-577] | 402 [59-764] |
| g_1 | -464 | 4012* [-48 to 9304] | -428 [-800 to -104] |
| g_2 | 4065 | 5844* [2792-9552] | 4028* [1472-6936] |
| D (split) | 0.000403 | 0.00043* [0.00025-0.00062] | 0.00057* [0.00042-0.00078] |
With its own ancestor the split time is right (0.00043 against 0.00040; the
two-population model put it at 0.00057), and the ancestral size is
recovered (Theta_3 0.00140 against 0.00143: 17,500 individuals against the
published 17,934). This supports the explanation of section 4: the
two-population model moved the split back in time because its ancestor was
too small. The price is precision: the Bornean growth rate is no longer
determined (its interval covers both signs and its median has the wrong
sign), and the intervals of Theta_2 and g_2 are wider. In norec3.txt
Theta_3 is not determined (0.00096, 0-0.0040) and D stays wide (0.00072,
0.00016-0.0031).
| Data | Model | TI | BTI | SS |
|---|---|---|---|---|
| rec.txt | two populations, growth | -145992.5 | -145932.5 | -145775.2 |
| rec3.txt | three populations | -146001.2 | -145940.2 | -145773.2 |
| norec.txt | two populations, growth | -145793.8 | -145728.7 | -145543.8 |
| norec3.txt | three populations | -145803.7 | -145737.4 | -145537.4 |
With five heated chains, as in these runs, TI and BTI prefer the
two-population model by 8-10 log units, while SS prefers the ancestor by 2-6.
Neither margin holds up with a longer ladder. With 16 chains
(heating=YES:1:POWER:16) the two models tie on rec.txt (BTI, joint
row: 0.3 log units), so five chains were too few for this comparison
(05-model-selection).
How many loci does the ancestor need?
scripts/simulate_series.py simulates 80 new loci from the same model (with
recombination; its first 20 loci are rec.txt) and writes
data/series/rec{40,80}.txt and rec{40,80}_3.txt. These files (24 MB) are
not in the repository; run the script to make them. All runs below used
migrate-n 6.1.96 with 16 chains on beerli_q/backfill2 with 21-60 MPI
processes. Values are BTI, ancestor model minus two-population model;
positive favours the ancestor:
| Loci | Replicates | All (independent parameters) | All (joint) | Median reweighting ESS, two-pop / ancestor |
|---|---|---|---|---|
20 (norec.txt) | 1 | +7.1 | -2.2 | 85 / 62 |
20 (rec.txt) | 1 | +6.1 | +0.3 | 86 / 70 |
| 40 | 1 | +9.3 | -4.6 | 58 / 55 |
| 80 | 1 | +37.9 | -11.4 | 63 / 59 |
| 80 | 4 | +21.6 | -14.8 | 76 / 57 |
| 80 | 8, joint-samples=40000 | +16.8 | -9.7 | 87 / 116 |
The (independent parameters) row gives every locus its own parameters (the
product of the per-locus marginal likelihoods). The (joint) row shares one
set of parameters across all loci, which is the model being compared. The two
rows disagree:
- The independent row favours the ancestor, and more so with more loci. Its 80-locus margin shrinks with more replicates (+37.9, +21.6, +16.8), so a single run overstates it.
- The joint row is near zero at 20 loci and favours the two-population model from 40 loci on, by 5 to 15 log units. No joint combination collapsed (all median reweighting ESS 55 or more), but with one to four replicates most of the ancestor model’s Joint rows are starred (7 to 9 of 11, section 7). With eight replicates and four times the genealogies per locus only its two split times are (2 of 11; two-population model 3 of 8), and the MC errors of the joint marginal likelihoods (0.8 and 1.5) are far smaller than the 9.7 log units between the models.
The ancestor model’s Joint medians and 95% intervals (truth: Theta_3 0.00143, D 0.000403):
| Loci | Replicates | Theta_3 | D |
|---|---|---|---|
20 (rec.txt) | 1 | 0.00146 [0.00089-0.00203] | 0.00039 [0.00026-0.00064] |
| 40 | 1 | 0.00124 [0.00086-0.00164] | 0.00047* [0.00039-0.00073] |
| 80 | 1 | 0.00107* [0.00085-0.00131] | 0.00041* [0.00034-0.00048] |
| 80 | 4 | 0.00095* [0.00069-0.00121] | 0.00048* [0.00038-0.00062] |
| 80 | 8, joint-samples=40000 | 0.00103 [0.00082-0.00124] | 0.00039* [0.00029-0.00048] |
The split time is right at every size: all intervals cover the truth. The ancestral Theta_3 drifts down as loci are added, and from 80 loci on its interval misses the truth. The 8-replicate run settles this: its estimates are stable (Theta_3 is no longer starred), and they are 30% too small for the ancestor.
At 80 loci the joint marginal likelihood prefers the two-population model, although the data were simulated with the ancestor. Both models’ joint combinations work, so this is not a numerical failure: the ancestor model spends three more parameters, and these data do not pay for them. A model choice answers which model the data support, not which model is true; the true model has to earn its extra parameters.
A Bornean skyline instead of an ancestor
A parametric skyline (04-skyline) gives the ancestor its own size without a
third population. The Bornean population continues the ancestral lineage
(section 3), so a second segment for its Theta, older than the split (backward
in time), stands for the ancestor. parmfile.rec-skyline uses the
two-population model of sections 3-7 with
mig-histogram=ALL:0.00005:mighistfile
skyline=PARAM:2:0.00005:skylinefile
skyline-times={0.0005}
skyline-model={* c c c}
population-growth={1 2}
skyline-model lists the parameters in the order of custom-migration:
Theta_1 gets a multiplier for the segment older than 0.0005 (*), the two
migration rates and Theta_2 stay constant (c). With growth, a * entry
restarts its exponential growth at the start of each segment (backward in
time): the Bornean Theta at time t in the older segment is Theta_1 times
the multiplier times exp(-g_1 (t - 0.0005)). The boundary 0.0005 is fixed,
a little older than the split estimates of section 8. Skyline with growth
needs 6.1.94 or 7.0.118; older versions refuse * together with growth.
The runs used rec.txt (20 loci), 16 chains (parmfile.rec-skyline has
five; change its heating line) and 21 MPI processes on backfill2; the
skyline runs took 72 minutes ({* c c c}) and 78 minutes ({* c c *}). BTI
marginal likelihoods (joint MC error 0.6-0.7):
| Model | skyline-model | population-growth | All (independent parameters) | All (joint) |
|---|---|---|---|---|
| two populations (section 3) | - | {1 2} | -145769.0 | -145777.7 |
| unsampled ancestor | - | {1 2 0} | -145763.0 | -145777.4 |
| Bornean skyline | {* c c c} | {1 2} | -145766.0 | -145777.3 |
| both skylines | {* c c *} | {1 2} | -145763.4 | -145776.1 |
| both skylines, no growth | {* c c *} | {0} | -145770.8 | -145782.7 |
Joint medians and 95% intervals; the ancestral Theta is Theta_3 in the ancestor model and the Bornean Theta in the older segment in the skyline models (from the skyline multiplier table of the outfile):
| Parameter | True | two populations | ancestor | Bornean skyline | skylines, no growth |
|---|---|---|---|---|---|
| Theta_1 | 0.00070 | 0.00074 [0.00050-0.00097] | 0.00088 [0.00051-0.00139] | 0.00071 [0.00049-0.00092] | 0.00069 [0.00052-0.00089] |
| ancestral Theta | 0.00143 | - | 0.00146 [0.00089-0.00203] | 0.00120 [0.00057-0.00238] | 0.00124 [0.00077-0.00180] |
| Theta_2 | 0.00301 | 0.00331* [0.00176-0.00567] | 0.00364 [0.00195-0.00595] | 0.00309 [0.00165-0.00528] | 0.00186 [0.00142-0.00237] |
| g_1 | -464 | -412 [-800 to -64] | 4116* [-960 to 8944] | -132 [-808 to 560] | - |
| g_2 | 4065 | 4228* [1304-7064] | 6644* [2440-10000] | 3532* [792-6352] | - |
| D (split) | 0.000403 | 0.00057 [0.00035-0.00144] | 0.00039 [0.00026-0.00064] | 0.00060* [0.00037-0.00103] | 0.00053 [0.00039-0.00146] |
- All four models with growth tie on the joint row (within 1.6 log units, about twice the MC error); 20 loci cannot separate them. Without growth the skyline model is 5.0-6.6 log units worse: the Sumatran expansion matters more than the size of the ancestor.
- The Bornean skyline recovers the ancestral size nearly as well as the ancestor model (0.00120 and 0.00146 against 0.00143). The two joint combinations are about equally healthy: four starred rows each, median reweighting ESS 85 (skyline) and 70 (ancestor).
- The split time does not move: the skyline gives the ancestor its size but keeps the Bornean population as the ancestral lineage, so D stays where the two-population model put it (0.00060 against 0.00040). Only the ancestor model with its own population moves D to the truth (0.00039).
- As in the ancestor model the Bornean growth rate is no longer determined: its interval covers both signs.
- A skyline segment for the Sumatran Theta (
{* c c *}) adds nothing: backward in time the Sumatran lineages have all moved into population 1 at the split, so the older Sumatran segment is empty and its multiplier returns the prior (0.98, 0.19-6.7). The marginal likelihood does not penalise it (-145776.1 against -145777.3), but it should not be reported.
9. What next
- More individuals or loci would sharpen the split time and the Bornean growth rate; the model mismatch of the ancestral size (section 3) remains.
- Other stdpopsim models with two or three populations and migration
(
HomSap OutOfAfrica_2T12,AnaPla MallardBlackDuck_2L19) would make 11b and 11c. - 05-model-selection shows how many heated chains a reliable comparison needs; sections 3-7 used five, the loci series of section 8 sixteen.
References
Locke DP et al. (2011) Comparative and demographic analysis of orang-utan genomes. Nature 469:529-533.
Adrion JR et al. (2020) A community-maintained standard library of population genetic models. eLife 9:e54967.