Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

generalisedKinship

Generalised kinship coefficients


Description

Compute generalised single-locus kinship coefficients, using the algorithm by Weeks & Lange (1988).

Usage

generalisedKinship(x, pattern, mem = NULL, verbose = FALSE, debug = FALSE)

Arguments

x

A ped object.

pattern

A kinPattern object.

mem

An environment (for internal use).

verbose

A logical.

debug

A logical.

Value

A single probability.

References

Weeks and Lange. The Affected-Pedigree-Member Method of Linkage Analysis. Am. J. Hum. Genet. 42:315-326, 1988.

Examples

x = nuclearPed(3)
kp = kinPattern(x, list(c(1,1,1)))
generalisedKinship(x, kp)


##### IBD coefficients via generalised kinship ###
#(Clearly not the simplest way; serves as a check)
IBD_from_gk = function(x, ids) {
  fa1 = father(x, ids[1])
  fa2 = father(x, ids[2])
  mo1 = mother(x, ids[1])
  mo2 = mother(x, ids[2])
  GK = function(...) generalisedKinship(x, list(...))

  k0 = GK(fa1, fa2, mo1, mo2)
  k1 = GK(c(fa1, fa2), mo1, mo2) + GK(c(fa1, mo2), fa2, mo1) +
       GK(c(mo1, fa2), fa1, mo2) + GK(c(mo1, mo2), fa1, fa2)
  k2 = GK(c(fa1, fa2), c(mo1, mo2)) + GK(c(fa1, mo2), c(mo1, fa2))
  c(k0, k1, k2)
}

y1 = nuclearPed(2); ids = 3:4
stopifnot(IBD_from_gk(y1, ids) == kappaIBD(y1, ids))

y2 = quadHalfFirstCousins()
ids = 9:10
stopifnot(IBD_from_gk(y2, ids) == kappaIBD(y2, ids))

#### Triple/quad kinship (compare with karigl)
x = fullSibMating(1)
ids = c(1,5,6)
stopifnot(generalisedKinship(x, list(ids)) == generalisedKinship3(x, ids))
ids = c(1,5,6,5)
stopifnot(generalisedKinship(x, list(ids)) == generalisedKinship4(x, ids))

ribd

Pedigree-based Relatedness Coefficients

v1.2.0
GPL-3
Authors
Magnus Dehli Vigeland [aut, cre] (<https://orcid.org/0000-0002-9134-4962>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.