Overview

This document is to highlight some of the capabilities using R for plotting pedigree data.

The ‘kinship2’ Package

This package has some sample pedigree data. We will use that to take a quick look of pedigree plotting using R.

Load a sample pedigree dataset

library(kinship2)
## Loading required package: Matrix
## Loading required package: quadprog
data(sample.ped)

This following code loads 5 data fields:

  • Person ID
  • Father ID
  • Mother ID
  • Person gender
  • Person Family ID
pedAll <- pedigree(
        id=sample.ped$id, 
        dadid=sample.ped$father, 
        momid=sample.ped$mother,
        sex=sample.ped$sex, 
        famid=sample.ped$ped)
print(pedAll)
## Pedigree list with 55 total subjects in 2 families
  • Noticed that we have not touched any disease states in this plot.

Plot first family

  • This first plot is for family 1.
ped1basic <- pedAll['1']
plot(ped1basic, main = "First Family")

## Did not plot the following people: 113

Plot second family

  • This second plot is for family 2.
ped2basic <- pedAll['2']
plot(ped2basic, main = "Second Fammily")

Demo Affected Indicators with Relationships

We will add additional details to the plot, we will add the following:

  • show affected status (for disease state)
  • show 210 and 211 are monozygotic twins (must be of same gender)
  • show 212 and 213 are dizygotic twins.

Some of the relationship codes are:

  1. Monozygotic twin
  2. Dizygotic twin
  3. Twin of unknown zygosity
  4. Spouse
sample.ped2 = subset(sample.ped, ped == 2)
id1 = c(210, 212)
id2 = c(211, 213)
r = c(1, 2)
rm = cbind(id1, id2, r)

pedAll <- pedigree(
    id = sample.ped2$id, 
    dadid = sample.ped2$father, 
    momid = sample.ped2$mother, 
    sex = sample.ped2$sex, 
    affected = sample.ped2$affected, 
    status = sample.ped2$status, 
    relation = rm)
plot(pedAll, main = "Twins: 210-211, 212-213")

Demo Genotype Annotation

The following sample is based on this Pedigree-drawing with R and graphviz article.

First, create a CSV file

Here is a quick look of the data file.

cat test.pre
## "id" "fid"   "mid"   "sex"   "aff"   "GABRB1"    "D4S1645"
## 1    2   3   2   2   7/7 7/10    
## 2    0   0   1   1   -/- -/- 
## 3    0   0   2   2   7/9 3/10    
## 4    2   3   2   2   7/9 3/7 
## 5    2   3   2   1   7/7 7/10    
## 6    2   3   1   1   7/7 7/10    
## 7    2   3   2   1   7/7 7/10    
## 8    0   0   1   1   -/- -/- 
## 9    8   4   1   1   7/9 3/10    
## 10   0   0   2   1   -/- -/- 
## 11   2   10  2   1   7/7 7/7 
## 12   2   10  2   2   6/7 7/7 
## 13   0   0   1   1   -/- -/- 
## 14   13  11  1   1   7/8 7/8 
## 15   0   0   1   1   -/- -/- 
## 16   15  12  2   1   6/6 7/7 

Load CSV file then plot the pedigree tree

  • noticed that the affected persons are showing with filled circles.
  • Also each person is annotated with genotype from GABARB1 and D4S1645 genes.
p1 <- read.table("test.pre", header=T)
p2 <- as.data.frame(p1)
attach(p2)
ped <- pedigree(id,fid,mid,sex,aff)
par(xpd = TRUE)
strid<-paste(id, GABRB1, D4S1645, sep="\n")
plot(ped,id=strid)