Using dot to draw pedigrees

I have been looking for an easy to use pedigree drawing package to run under Linux. I downloaded the graphviz set of programs, wondering if they could be turned to this purpose, and found them very useful.

The Graph Visualisation Project (see www.research.att.com/sw/tools/graphviz/ and www.graphviz.org) is a suite of programs for automated layout and drawing of directed and undirected graphs. A simple language is used to specify the nodes and edges of the graph. The programs take these scripts and display the graph, minimizing line (edge) crossings, and smoothing kinks in lines (splines).

Pedigrees are of course directed graphs (and hierarchical trees), so it is easy to get dot, the main drawing program, to render marriage node pedigree drawings. Here is a simple example:

digraph ped1 {
label="A simple nuclear family" ;
"1" [shape=box, regular=1] ;
"2" [shape=circle] ;
"3" [shape=box, regular=1] ;
"4" [shape=circle] ;
"1x2" [shape=diamond,style=filled,label="",height=.1,width=.1] ;
"1" -> "1x2" [dir=none] ;
"2" -> "1x2" [dir=none] ;
"1x2" -> "3" [dir=none] ;
"1x2" -> "4" [dir=none,style=filled,color=grey] ;
}
Pedigree drawing of a simple nuclear family

The dir value ensures no arrowheads are placed on the lines, and the height and width of graphical objects are in inches. The label value was set to empty for the marriage node, to avoid the default behaviour of printing all node names. Setting regular=1 ensures the male box is square.

The script was sent to dot as:

dot -Tps -o first.ps first.dot

The available formats include GIF (-Tgif) and JPEG (-Tjpg), as well as Postscript and PDF.

The program really shines for larger and more complex pedigrees, where the layout of the diagrams remains easy for the eye to interpret. Here is a well-known example of a inbred pedigree (opposite). Points to note are that each generation is placed on the same line, unless this would make the diagram too cluttered, and that the edges smoothly curve around obstacles if this is the neatest alternative.

Diagrams can be refined using a WYSIWYG editor dotty.

If one has specified the page size eg

page="8.2677165,11.692913" ; /* A4 page size */
margin="0,0" ; /* default margin is 0.5 inches */

then large pedigrees are appropriately printed onto multiple sheets to be joined up later (each page's position in the total diagram is labelled in small print in the corner).

It may be sometimes necessary to increase the vertical distance between each generation via:

ranksep=1.5 ; /* default separation between ranks is 0.75 inches */

if there are many line crossings, so that the diagram doesn't look so cluttered.

I have written a shell script to automatically render Linkage or Gas format pedigree files, as well as adding a write dot command to my Sib-pair program.

Pedigree drawing of a larger inbred family

More recently, I have written a similar script to draw haplotypes generated by SIMWALK2 (reads the "HAPLO-index.00N" files): drawhap.sh. This uses the "HTML-like" commands added to recent versions of dot. This is a preliminary version, in that I hope to intelligently colour the haplotypes (updated 9th June 2006).