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/57a54f343dc338f5362cc17f493e498ef765e6ed9eb65f04060a64b17c4e0140.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/15133944807eb1c2445d42df4d6aeeb4819e2b4f958d50cca61b519374e50d4c.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/a932f740ff41909e454fe418ccf58aa870fad2f97e6bedf0f58eb0f285d12abd.svg