LD_mult: Compute linkage disequilibrium (LD) among several loci

Description Usage Arguments Details Author(s) See Also Examples

Description

Compute the linkage disequilibrium (LD) among several combinations of loci.

Usage

1
2
LD_mult(X, matr, pos = NULL, is_phased = TRUE, any_na = FALSE,
  r_only = FALSE, check = TRUE)

Arguments

X

A numeric matrix. The genotypes of the loci. If the genotypes are phased, these must only contain 0 and 1. If they are unphased, they must only contain 0, 1, or 2, where 1 codes for the heterozygot.

matr

A numeric Matrix with three columns. The first two columns specify the indices of the loci in X for which (LD) is computed.

pos

An increasingly sorted numeric vector. The positions of the loci.

is_phased

A logical. Are the data phased?

any_na

A logical. May some genotypes contain missing values? If not, computations are more efficient for phased genotypes.

r_only

Should only the r-statistic be computed? (Produces minimal output for saving memory and computation time.)

check

A logical. Should checks be performed?

Details

For the documentation of the calculated LD statistics, see LD.

Author(s)

Dominik Mueller (dominikmueller64@yahoo.de)

See Also

transform_geno, LD, comb_all, comb_adj, comb_nearest, comb_wind, comb_sliding.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## Not run: 
data('population', package = 'LDtools')
pos <- map$pos

# Adjacent loci
mean(LD_mult(X, comb_adj(pos), check = FALSE)$r2, na.rm = TRUE)

# Nearest loci
i <- sort(sample(seq_along(pos), size = 1000L))
i2 <- setdiff(seq_along(pos), i)
mean(LD_mult(X, comb_nearest(i, i2, pos[i], pos[i2]), check = FALSE)$r2, na.rm = TRUE)
mean(LD_mult(X, comb_nearest_k(i, i2, pos[i], pos[i2], 2), check = FALSE)$r2, na.rm = TRUE)

# Flanking loci
mean(LD_mult(X, comb_flank(i, i2, pos[i], pos[i2]), check = FALSE)$r2, na.rm = TRUE)

# Sliding window
matr <- comb_sliding(pos, start = 0, width = 5, advance = 0.25)
dat <- LD_mult(X, matr, pos, check = FALSE)

dat <- by(data = dat, INDICES = factor(dat$block),
          FUN = function(x) {
          data.frame(pos = mean(c(x$pos1, x$pos2)),
                     r = mean(x$r, na.rm = TRUE))
          },
          simplify = FALSE)
dat <- do.call(rbind, dat)
with(dat, plot(pos, r, type = 'l'))

## End(Not run)

DominikMueller64/LDtools documentation built on May 6, 2019, 2:51 p.m.