Learn R Programming

SNPRelate (version 1.6.4)

snpgdsLDpair: Linkage Disequilibrium (LD)

Description

Return a LD value between snp1 and snp2.

Usage

snpgdsLDpair(snp1, snp2, method = c("composite", "r", "dprime", "corr"))

Arguments

snp1
a vector of SNP genotypes (0 -- BB, 1 -- AB, 2 -- AA)
snp2
a vector of SNP genotypes (0 -- BB, 1 -- AB, 2 -- AA)
method
"composite", "r", "dprime", "corr", see details

Value

Return a numeric vector:
ld
a measure of linkage disequilibrium
if method = "r" or "dprime",
pA_A
haplotype frequency of AA, the first locus is A and the second locus is A
pA_B
haplotype frequency of AB, the first locus is A and the second locus is B
pB_A
haplotype frequency of BA, the first locus is B and the second locus is A
pB_B
haplotype frequency of BB, the first locus is B and the second locus is B

Details

Four methods can be used to calculate linkage disequilibrium values: "composite" for LD composite measure, "r" for R coefficient (by EM algorithm assuming HWE, it could be negative), "dprime" for D', and "corr" for correlation coefficient. The method "corr" is equivalent to "composite", when SNP genotypes are coded as: 0 -- BB, 1 -- AB, 2 -- AA.

References

Weir B: Inferences about linkage disequilibrium. Biometrics 1979; 35: 235-254.

Weir B: Genetic Data Analysis II. Sunderland, MA: Sinauer Associates, 1996.

Weir BS, Cockerham CC: Complete characterization of disequilibrium at two loci; in Feldman MW (ed): Mathematical Evolutionary Theory. Princeton, NJ: Princeton University Press, 1989.

See Also

snpgdsLDMat, snpgdsLDpruning

Examples

Run this code
# open an example dataset (HapMap)
genofile <- snpgdsOpen(snpgdsExampleFileName())

snp1 <- read.gdsn(index.gdsn(genofile, "genotype"), start=c(1,1), count=c(1,-1))
snp2 <- read.gdsn(index.gdsn(genofile, "genotype"), start=c(2,1), count=c(1,-1))

snpgdsLDpair(snp1, snp2, method = "composite")
snpgdsLDpair(snp1, snp2, method = "r")
snpgdsLDpair(snp1, snp2, method = "dprime")
snpgdsLDpair(snp1, snp2, method = "corr")

# close the genotype file
snpgdsClose(genofile)

Run the code above in your browser using DataLab