Description Usage Arguments Details Value Author(s) References See Also Examples
Return a LD matrix for SNP pairs.
1 2 3 |
gdsobj |
an object of class |
sample.id |
a vector of sample id specifying selected samples; if NULL, all samples are used |
snp.id |
a vector of snp id specifying selected SNPs; if NULL, all SNPs are used |
slide |
# of SNPs, the size of sliding window; if |
method |
"composite", "r", "dprime", "corr", "cov", see details |
mat.trim |
if |
num.thread |
the number of (CPU) cores used; if |
with.id |
if |
verbose |
if TRUE, show information |
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.
If slide <= 0
, the function returns a n-by-n LD matrix where the
value of i row and j column is LD of i and j SNPs. If slide > 0
, it
returns a m-by-n LD matrix where n is the number of SNPs, m is the size of
sliding window, and the value of i row and j column is LD of j and j+i SNPs.
Return a list:
sample.id |
the sample ids used in the analysis |
snp.id |
the SNP ids used in the analysis |
LD |
a matrix of LD values |
slide |
the size of sliding window |
Xiuwen Zheng
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.
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 | # open an example dataset (HapMap)
genofile <- snpgdsOpen(snpgdsExampleFileName())
# missing proportion and MAF
ff <- snpgdsSNPRateFreq(genofile)
# chromosome 15
snpset <- read.gdsn(index.gdsn(genofile, "snp.id"))[
ff$MissingRate==0 & ff$MinorFreq>0 &
read.gdsn(index.gdsn(genofile, "snp.chromosome"))==15]
length(snpset)
# LD matrix without sliding window
ld.noslide <- snpgdsLDMat(genofile, snp.id=snpset, slide=-1, method="composite")
# plot
image(t(ld.noslide$LD^2), col=terrain.colors(16))
# LD matrix with a sliding window
ld.slide <- snpgdsLDMat(genofile, snp.id=snpset, method="composite")
# plot
image(t(ld.slide$LD^2), col=terrain.colors(16))
# close the genotype file
snpgdsClose(genofile)
|
Loading required package: gdsfmt
SNPRelate -- supported by Streaming SIMD Extensions 2 (SSE2)
[1] 203
Linkage Disequilibrium (LD) estimation on genotypes:
# of samples: 279
# of SNPs: 203
using 1 thread
method: composite
LD matrix: the sum of all selected genotypes (0,1,2) = 56582
Linkage Disequilibrium (LD) estimation on genotypes:
# of samples: 279
# of SNPs: 203
using 1 thread
sliding window size: 203
method: composite
LD matrix: the sum of all selected genotypes (0,1,2) = 56582
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.