pegas (version 0.10)

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, 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.

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 plot.default.

Value

an object of class "dist" for LDscan.

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.

See Also

LD, read.vcf

Examples

Run this code
# 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 DataLab