Drawing pedigree examples using the kinship R package

I have previously provided sort of an overview about plotting the pedigrees, then specifically using the Graphiviz, while I have lately used the TikZ LaTeX (see slides 11-15) system (see more example). The later gives great (beautiful) results, but at the cost of writing TikZ code - it is not that horible, just time consuming - the same applies to Graphviz. Is there a quick way to plot a pedigree if we already have the data in the file. It is possible to do it in R using the kinship package. Here is an example:
ped <- data.frame( id=c( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11),
fid=c( 0, 0, 0, 3, 3, 5, 3, 6, 6, 0, 9),
mid=c( 0, 0, 0, 2, 1, 4, 4, 7, 7, 0, 10),
sex=c( 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2),
ped[11, "aff"] <- 1

ped <- with(ped, pedigree(id=id, dadid=fid, momid=mid, sex=sex, affected=aff))
Which gives the following result. It is not great, but it is informative and easy to do. From a practical point of implementation all pedigree members need to have both parents known or no parents known.

1 comment:

cros david said...

In R it is also possible to draw a pedigree with pedantics package. With your example, this would be :
frame() #to make empty plot first
colnames(ped) <- c("id", "sire", "dam", "sex", "aff")
drawPedigree(ped[,c("id", "dam", "sire")],sex=ped$sex, sexInd = c(1,2), dots='y',dotSize=0.005)

This is not nice but it works even if you only know one parent for some individuals, if you have many individuals without known sex, or if you have individuals used as males and females (like in plant species).

Without R I used pedimap (http://www.ncbi.nlm.nih.gov/pubmed/23087384).