pegas (version 0.12)

LDscan: Multi-Locus Linkage Disequilibrium

Description

LDscan computes a matrix of pairwise linkage disequilibrium (LD) coefficients (\(r^2\)) from a set of loci (which must be bi-allelic; if not, the results are not guaranteed to be meaningful). The genotypes must be phased.

LDmap plots a matrix of LD coefficients, optionally with the positions of the loci.

Usage

LDscan(x, ...)

# S3 method for DNAbin LDscan(x, quiet = FALSE, ...) # S3 method for loci LDscan(x, depth = NULL, quiet = FALSE, ...)

LDmap(d, POS = NULL, breaks = NULL, col = NULL, border = NA, angle = 0, asp = 1, cex = 1, scale.legend = 0.8, ...)

Arguments

x

an object of class "loci" with phased genotypes.

depth

a vector of integers giving the the depth(s) (or lags) at which the \(r^2\)'s are calculated. By default, all possible depths are considered.

quiet

a logical: should the progress of the operation be printed?

d

a correlation matrix (can be an object of class "dist").

POS

an optional vector of locus positions (e.g., from a VCF file; see examples).

breaks

a vector of break intervals to count the values in d; by default, ten equally-sized intervals are used.

col

an optional vector of colours; a scale from lightyellow to red is used by default.

border

the border of the rectangles: the default is to have no border (this is not the same than default in rect; see examples).

angle

value (in degrees) to rotate the graphic.

asp

the aspect ratio of the graphic; one by default so the elements are squares (not rectangles).

cex

the scaling of the labels and text.

scale.legend

the scaling of the legend rectangles.

further arguments passed to methods (LDscan) or to plot.default (LDmap).

Value

LDscan returns an object of class "dist" by default, or a list if depth is used.

Details

The LD coefficient \(r^2\) is well defined when the two loci have only two alleles. In other cases, LD is well defined (see LD) but the definition of \(r^2\) is not clear.

All levels of ploidy are accepted, but all loci should have the same ploidy level.

If depth is used, the \(r^2\)'s are calculated only for the pairs of loci that are distant by these values in x, but necessarily on the chromosome. The returned list has names set with the values of depth.

See Also

LD, read.vcf

Examples

Run this code
# NOT RUN {
data(woodmouse)
d <- LDscan(woodmouse)
LDmap(d, seg.sites(woodmouse), seq(0, 1, .1))

# }
# NOT RUN {
## Download the VCF file from Dryad:
## http://dx.doi.org/10.5061/dryad.446sv.2

## the VCF file should have this name:
fl <- "global.pop.GATK.SNP.hard.filters.V3.phased_all.pop.maf.05.recode.vcf.gz"

info.fly <- VCFloci(fl)

bks <- seq(0, 1, 0.2)

## LD map from the first 100 loci:
x <- read.vcf(fl, to = 100) # read only 100 loci
res <- LDscan(x)
LDmap(res, info.fly$POS[1:100], bks, scale.legend = 3)

## check the chromosomes:
table(info.fly$CHROM)

## LD map from 100 loci randomly distributed on the chromosome:
s <- ceiling(seq(1, 224253, length.out = 100))
xs <- read.vcf(fl, which.loci = s)
res2 <- LDscan(xs)
LDmap(res2, info.fly$POS[s], bks, scale.legend = 3)

## something simpler with 10 loci:
x10 <- x[, 1:10]
## the VCF file has no locus IDs, so we give some here:
names(x10) <- paste0("Loc", 1:10)
res10 <- LDscan(x10, quiet = TRUE)
LDmap(res10, angle = 45, border = NULL)
# }

Run the code above in your browser using DataCamp Workspace