Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

LD

Linkage Disequilibrium


Description

Compute Linkage Disequilibrium (LD) between given SNPs.

Usage

LD(x, lim, lim2, measure = c("r2", "r", "D"), trim = TRUE)

Arguments

x

A bed.matrix

lim

Range of SNPs for which the LD is computed

lim2

(Optional) Second range of SNPs (see Details)

measure

The LD measure

trim

Logical. If TRUE, the values above 1 or below -1 are replaced by 1 and -1 respectively.

Details

If lim2 is missing, the LD is computed between all SNPs with indices between lim[1] and lim[2]; else, the LD is computed between the SNPs in the range given by lim and those in the range given by lim2.

Note that the LD estimates are moment estimates (which are less precise than Maximum Likelihood Estimates). If standardize(x) = "none", x will be standardized using x@mu and x@sigma. If standardize(x) = "p", the moment estimates can produce r values outside of the range [-1;1], hence the parameter trim. We recommend to set standardize(x) <- "mu" (trimming can still be necessary due to rounding errors).

Value

A matrix of LD values.

Author(s)

Hervé Perdry and Claire Dandine-Roulland

See Also

Examples

# Load data
data(AGT)
x <- as.bed.matrix(AGT.gen, AGT.fam, AGT.bim)

# Compute LD
ld.x <- LD(x, c(1,ncol(x)))

# Plot a tiny part of the LD matrix
LD.plot( ld.x[1:20,1:20], snp.positions = x@snps$pos[1:20] )

gaston

Genetic Data Handling (QC, GRM, LD, PCA) & Linear Mixed Models

v1.5.7
GPL-3
Authors
Hervé Perdry [cre, aut, cph], Claire Dandine-Roulland [aut, cph], Deepak Bandyopadhyay [cph] (C++ gzstream class), Lutz Kettner [cph] (C++ gzstream class)
Initial release
2020-09-18

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.