Indeed there are multiple packages to compute LD. However, you actually don't need any package since the core R functions are sufficient.
So given a $n\times p$ genotype matrix $m$ with $n$ subjects and $p$ SNPs (genotypes are usually called the alleles, or the value in the cells, while SNPs are the columns) you can use cor(m)
of the genotype matrix to obtain the pairwise correlations.
The coding of the alleles (or the cells) is usually done the following:
- 2 Homozygous for first allele
- NA Missing genotype
- 1 Heterozygous
- 0 Homozygous for second allele
The first allele is usually the minor allele.
If you really want the significance levels of the pairwise correlations as well you can use the rcor()
function from the package Hmisc
. If you want some nice heatmaps, look also at LDheatmap
.
However, please take a look at plink. Plink is the most commonly used software to analyse these kind of data and basically standard for association studies.