Linkage disequilibrium

Gota Morota
http://morotalab.org/

2/5/2020

Background

This exercise illustrates how to calculate linkage disequilibrium (LD) among genetic markers.

Install and load R packages

We will analyze the mice data included in the BGLR package. The genetics package includes the LD() function to calculate \(D\).

rm(list=ls()) # delete the objects in the current environment 

install.packages("BGLR")
install.packages("genetics")

library(BGLR)
library(genetics)

data(mice)
?mice
W <- mice.X[, 1:10] # use the first 10 markers

D

The makeGenotypes() function converts columns in a dataframe to genotypes or haplotypes. The LD function computes LD statistics.

?makeGenotypes
W2 <- makeGenotypes(W, convert=c(colnames(W)), method=as.genotype.allele.count)

?LD
myLD <- LD(W2)
names(myLD)
myLD$D

\(r^2\)

\(r^2\) of Hill and Robertson (1968).

myLD$r
myLD$r^2

Alternative coding

W3 <- W # create a copy of W

# Convert to characters
W3[W3==0] <- "A/A"
W3[W3==1] <- "A/T"
W3[W3==2] <- "T/T"
W3


?makeGenotypes
W4 <- makeGenotypes(W3)
LD(W4)$r^2