Quickstart

DemesDraw is a python package for drawing Demes demographic models. It can be installed with pip.

python3 -m pip install demesdraw

Or with conda.

conda install -c conda-forge demesdraw

Population size history

The size_history() function plots the population size as a function of time for each deme in the graph. This is great for single-deme graphs like the ZigZag model from Schiffels & Durbin et al. (2014).

Hide code cell source
zigzag = demes.load("../examples/stdpopsim/HomSap__Zigzag_1S14.yaml")
demesdraw.size_history(zigzag, invert_x=True, log_time=True);
_images/fff51957b4011002961051a0a8df5543e048e1f9f8416cd2d148e74ecfd3deb4.svg

Multi-deme models can also be plotted with size_history(). E.g., below we plot the human out-of-Africa model from Gutenkunst et al. (2009). Lines for distinct demes are given different colours and widths, with thinner lines drawn on top of thicker lines. Ancestor/descendant relationships are indicated as dotted lines.

Hide code cell source
gutenkunst_ooa = demes.load("../examples/stdpopsim/HomSap__OutOfAfrica_3G09.yaml")
demesdraw.size_history(gutenkunst_ooa, invert_x=True, log_size=True);
_images/52001ab2d8c4a94983249b9b8969beac4398d09e3051afcf044ab301c1979a7b.svg

Demes as tubes

The tubes() function plots a “demes as tubes”-style schematic overview. Compared with the size-history figure above, this more fully captures the relationships between demes. Ancestor/descendant relationships are indicated as solid lines with open arrow heads pointing from ancestor to descendant, and migrations are drawn as thin lines with closed arrow heads pointing from source to destination.

Hide code cell source
gutenkunst_ooa = demes.load("../examples/stdpopsim/HomSap__OutOfAfrica_3G09.yaml")
demesdraw.tubes(gutenkunst_ooa, num_lines_per_migration=6, log_time=True, seed=1234);
_images/625767cd1d0a8cf1feb8ffa7114926b04fe024d674bacb09cb007851f4d80243.svg