ld {snpStats} | R Documentation

## Pairwise linkage disequilibrium measures

### Description

This function calculates measures of linkage disequilibrium between pairs of SNPs. The two SNPs in each pair may both come from the same `SnpMatrix` object, or from two different `SnpMatrix` objects. Statistics which can be calculated are the log likelihood ratio, odds ratio, Yule's Q, covariance, D-prime, R-squared, and R.

### Usage

    ld(x, y = NULL, depth = NULL, stats, symmetric = FALSE)

### Arguments

`x` | An object of class `SnpMatrix` or `XSnpMatrix`
`y` | (Optional) Another object of the same class as `x`. If `y` is supplied, LD statistics are calculated between each column of `x` and each column of `y`. Otherwise, they are calculated between columns of `x`
`depth` | When `y` is not supplied, this parameter is mandatory and controls the maximum lag between columns of `x` considered. Thus, LD statistics are calculated between `x[,i]` and `x[,j]` only if `i` and `j` differ by no more than `depth`
`stats` | A character vector specifying the linkage disequilibrium measures to be calculated. This should contain one or more of the strings: `"LLR"`, `"OR"`, `"Q"`, `"Covar"`, `"D.prime"`, `"R.squared"`, ad `"R"`
`symmetric` | When no `y` argument is supplied this argument controls the format of the output band matrices. If `TRUE`, symmetric matrices are returned and, otherwise, an upper triangular matrices are returned

### Details

For each pair of SNPs, phased haplotype frequencies are first estimated by maximum likelihood using the method described by Clayton and Leung (2007). The arrays of chosen LD statistics are then calculated and returned, either as band matrices (when `y` is not supplied), or as conventional rectangular matrices (when `y` is supplied). Band matrices are stored in compressed form as objects of class `dsCMatrix` (symmetric) or `dgCMatrix` (upper triangular). These classes are defined in the `"Matrix"` package)

### Value

If only one LD statistic is requested, the function returns either a matrix or a compressed band matrix. If more than one LD statistic is requested, a list of such objects is returned

### Author(s)

David Clayton dc208@cam.ac.uk

### References

Clayton and Leung (2007) Human Heredity, 64:45-51, (this paper is included in package documentation)

### See Also

`"Matrix-class"`

### Examples

    data(testdata)
    ld1 <- ld(Autosomes[, 1:50], depth=10, stats=c("D.prime", "R.squared"))
    ld2 <- ld(Autosomes[, 1:20], Autosomes[, 21:25], stats="R.squared")

[Package snpStats version 1.44.0 Index]