an object of class SNPGDSFileClass,
a SNP GDS file
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, see details
method
"composite", "r", "dprime", "corr", "cov", see details
mat.trim
if TRUE, trim the matrix when slide > 0:
the function returns a "num_slide x (n_snp - slide)" matrix
num.thread
the number of (CPU) cores used; if NA, detect
the number of cores automatically
with.id
if TRUE, the returned value with sample.id and
sample.id
verbose
if TRUE, show information
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.
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.
Value
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
Author(s)
Xiuwen Zheng
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
snpgdsLDpair, snpgdsLDpruning
Examples
# open an example dataset (HapMap)
genofile <- snpgdsOpen(snpgdsExampleFileName())
# chromosome 15
snpset <- read.gdsn(index.gdsn(genofile, "snp.id"))[
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)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(SNPRelate)
Loading required package: gdsfmt
SNPRelate -- supported by Streaming SIMD Extensions 2 (SSE2)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/SNPRelate/snpgdsLDMat.Rd_%03d_medium.png", width=480, height=480)
> ### Name: snpgdsLDMat
> ### Title: Linkage Disequilibrium (LD) analysis
> ### Aliases: snpgdsLDMat
> ### Keywords: GDS GWAS
>
> ### ** Examples
>
> # open an example dataset (HapMap)
> genofile <- snpgdsOpen(snpgdsExampleFileName())
>
> # chromosome 15
> snpset <- read.gdsn(index.gdsn(genofile, "snp.id"))[
+ read.gdsn(index.gdsn(genofile, "snp.chromosome")) == 15]
> length(snpset)
[1] 262
>
> # LD matrix without sliding window
> ld.noslide <- snpgdsLDMat(genofile, snp.id=snpset, slide=-1, method="composite")
Linkage Disequilibrium (LD) analysis on SNP genotypes:
Working space: 279 samples, 262 SNPs
Using 1 (CPU) core.
LD matrix: the sum of all selected genotypes (0, 1 and 2) = 73989
> # 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")
Linkage Disequilibrium (LD) analysis on SNP genotypes:
Working space: 279 samples, 262 SNPs
Using 1 (CPU) core.
Sliding window size: 250
LD matrix: the sum of all selected genotypes (0, 1 and 2) = 73989
> # plot
> image(t(ld.slide$LD^2), col=terrain.colors(16))
>
>
> # close the genotype file
> snpgdsClose(genofile)
>
>
>
>
>
> dev.off()
null device
1
>