This document is to highlight some of the capabilities using R for plotting pedigree data.
This package has some sample pedigree data. We will use that to take a quick look of pedigree plotting using R.
library(kinship2)
## Loading required package: Matrix
## Loading required package: quadprog
data(sample.ped)
This following code loads 5 data fields:
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
ped1basic <- pedAll['1']
plot(ped1basic, main = "First Family")
## Did not plot the following people: 113
ped2basic <- pedAll['2']
plot(ped2basic, main = "Second Fammily")
We will add additional details to the plot, we will add the following:
Some of the relationship codes are:
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")
The following sample is based on this Pedigree-drawing with R and graphviz article.
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
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)