snpgdsPairIBD: Calculate Identity-By-Descent (IBD) Coefficients

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/IBD.r

Description

Calculate the three IBD coefficients (k0, k1, k2) for non-inbred individual pairs by Maximum Likelihood Estimation (MLE) or PLINK Method of Moment (MoM).

Usage

1
2
3
snpgdsPairIBD(geno1, geno2, allele.freq, method=c("EM", "downhill.simplex", "MoM"),
	kinship.constraint=FALSE, max.niter=1000, reltol=sqrt(.Machine$double.eps),
	coeff.correct=TRUE, out.num.iter=TRUE, verbose=TRUE)

Arguments

geno1

the SNP genotypes for the first individual, 0 – BB, 1 – AB, 2 – AA, other values – missing

geno2

the SNP genotypes for the second individual, 0 – BB, 1 – AB, 2 – AA, other values – missing

allele.freq

the allele frequencies

method

"EM", "downhill.simplex", or "MoM", see details

kinship.constraint

if TRUE, constrict IBD coefficients ($k_0,k_1,k_2$) in the geneloical region ($2 k_0 k_1 >= k_2^2$)

max.niter

the maximum number of iterations

reltol

relative convergence tolerance; the algorithm stops if it is unable to reduce the value of log likelihood by a factor of $reltol * (abs(log likelihood with the initial parameters) + reltol)$ at a step.

coeff.correct

TRUE by default, see details

out.num.iter

if TRUE, output the numbers of iterations

verbose

if TRUE, show information

Details

If method = "MoM", then PLINK Method of Moment without a allele-count-based correction factor is conducted. Otherwise, two numeric approaches for maximum likelihood estimation can be used: one is Expectation-Maximization (EM) algorithm, and the other is Nelder-Mead method or downhill simplex method. Generally, EM algorithm is more robust than downhill simplex method.

If coeff.correct is TRUE, the final point that is found by searching algorithm (EM or downhill simplex) is used to compare the six points (fullsib, offspring, halfsib, cousin, unrelated), since any numeric approach might not reach the maximum position after a finit number of steps. If any of these six points has a higher value of log likelihood, the final point will be replaced by the best one.

Value

Return a data.frame:

k0

IBD coefficient, the probability of sharing ZERO IBD

k1

IBD coefficient, the probability of sharing ONE IBD

loglik

the value of log likelihood

niter

the number of iterations

Author(s)

Xiuwen Zheng

References

Milligan BG. 2003. Maximum-likelihood estimation of relatedness. Genetics 163:1153-1167.

Weir BS, Anderson AD, Hepler AB. 2006. Genetic relatedness analysis: modern data and new challenges. Nat Rev Genet. 7(10):771-80.

Choi Y, Wijsman EM, Weir BS. 2009. Case-control association testing in the presence of unknown relationships. Genet Epidemiol 33(8):668-78.

Purcell S, Neale B, Todd-Brown K, Thomas L, Ferreira MAR, Bender D, Maller J, Sklar P, de Bakker PIW, Daly MJ & Sham PC. 2007. PLINK: a toolset for whole-genome association and population-based linkage analysis. American Journal of Human Genetics, 81.

See Also

snpgdsPairIBDMLELogLik, snpgdsIBDMLE, snpgdsIBDMLELogLik, snpgdsIBDMoM

Examples

 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# open an example dataset (HapMap)
genofile <- openfn.gds(snpgdsExampleFileName())

YRI.id <- read.gdsn(index.gdsn(genofile, "sample.id"))[
	read.gdsn(index.gdsn(genofile, "sample.annot/pop.group"))=="YRI"]

# SNP pruning
set.seed(10)
snpset <- snpgdsLDpruning(genofile, sample.id=YRI.id, maf=0.05, missing.rate=0.05)
snpset <- sample(unlist(snpset), 250)

# the number of samples
n <- 25

# specify the allele frequencies
afreq <- snpgdsSNPRateFreq(genofile, sample.id=YRI.id, snp.id=snpset)$AlleleFreq
subMLE <- snpgdsIBDMLE(genofile, sample.id=YRI.id[1:n], snp.id=snpset,
	num.thread=2, allele.freq=afreq)
subMoM <- snpgdsIBDMoM(genofile, sample.id=YRI.id[1:n], snp.id=snpset,
	num.thread=2, allele.freq=afreq)


# genotype matrix
mat <- snpgdsGetGeno(genofile, sample.id=YRI.id[1:n], snp.id=snpset)
mat[!is.element(mat, c(0,1,2))] <- NA


rv <- NULL
for (i in 2:n)
{
	rv <- rbind(rv, snpgdsPairIBD(mat[,1], mat[,i], afreq, "EM"))
	print( snpgdsPairIBDMLELogLik(mat[,1], mat[,i], afreq,
		relatedness="unrelated", verbose=TRUE))
}
rv
summary(rv$k0 - subMLE$k0[1, 2:n])
summary(rv$k1 - subMLE$k1[1, 2:n])


rv <- NULL
for (i in 2:n)
	rv <- rbind(rv, snpgdsPairIBD(mat[,1], mat[,i], afreq, "MoM"))
rv
summary(rv$k0 - subMoM$k0[1, 2:n])
summary(rv$k1 - subMoM$k1[1, 2:n])


# close the genotype file
closefn.gds(genofile)

SNPRelate documentation built on May 2, 2019, 4:56 p.m.