I have to perform a linkage disequilibrium test between pairwise of SNPs. I have 3745 SNPs in 170 genotypes.

  • Which one of the packages would you recommend or have experience with and,
  • Most importantly; how do I have to set my data matrix to use well the package and functions (rows&columns).
  • 3
    $\begingroup$ Questions that are only about how to use R are off topic here (as are requests for packages / code, etc.). $\endgroup$ Feb 17, 2017 at 3:10
  • $\begingroup$ Try the Bioconductor list $\endgroup$
    – mdewey
    Feb 17, 2017 at 12:30

1 Answer 1


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.


Not the answer you're looking for? Browse other questions tagged or ask your own question.