Skip to content

Commit

Permalink
start updating recapitation vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen committed Dec 5, 2023
1 parent cacaabf commit b293bc6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion doc/short_vignettes/recapitation.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,26 @@ assert pop.generation == 10
Now we use `msprime` to coalesce the founder generation roots back to a common ancestor:

```{code-cell} python
import demes
import msprime
# Convert to tskit format
ts = pop.dump_tables_to_tskit()
num_roots_pre_recapitation = ts.first().num_roots
recapitated_ts = msprime.simulate(from_ts=ts)
yaml=f"""
time_units: generations
demes:
- name: deme0
epochs:
- start_size: {pop.N}
"""
graph = demes.loads(yaml)
demography = msprime.Demography.from_demes(graph)
recapitated_ts = msprime.sim_ancestry(demography=demography, initial_state=ts)
print(num_roots_pre_recapitation, recapitated_ts.first().num_roots)
```
Expand Down

0 comments on commit b293bc6

Please sign in to comment.