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/d444cf686f220020d8c0c3f4f8f4cf7ae938ff43613700bea21ca47c8b1a0712.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/8d09bb4a86a68a1ff65f9a063f2a0d14457fe583df90256e45b554e6e209288f.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/6ee3491570dc0bcaf824a737dda1fc1874f477a68f951b146dc239f3fde20114.svg