# NOT RUN {
######################
# Example 1: Full sibs
######################
x = nuclearPed(2)
k_0 = twoLocusKinship(x, ids = 3:4, rho = 0)
k_0.5 = twoLocusKinship(x, ids = 3:4, rho = 0.5)
stopifnot(k_0 == 1/4, k_0.5 == 1/16)
##################################################
# Example 2: Reproducing Fig. 3 in Thompson (1988)
# Note that in the article, curve (a) is wrong.
# See Erratum: https://doi.org/10.1093/imammb/6.1.1
##################################################
# Pedigrees (a) - (d)
ped.a = linearPed(3)
ped.b = halfCousinPed(0, removal = 1)
ped.c = cousinPed(1)
ped.d = doubleCousins(1, 1, half1 = TRUE, half2 = TRUE)
peds = list(
a = list(ped = ped.a, ids = c(1,7)),
b = list(ped = ped.b, ids = leaves(ped.b)),
c = list(ped = ped.c, ids = leaves(ped.c)),
d = list(ped = ped.d, ids = leaves(ped.d))
)
# Recombination values
rseq = seq(0, 0.5, length = 20)
# Compute two-locus kinship coefficients
kvals = sapply(peds, function(x) twoLocusKinship(x$ped, x$ids, rseq))
# Plot
matplot(rseq, kvals, type = "l", lwd = 2)
legend("topright", names(peds), col = 1:4, lty = 1:4, lwd = 2)
# }
Run the code above in your browser using DataLab