magnusdv / ribd

Computation of pedigree-based relatedness coefficients. Part of the ped suite packages for pedigree analysis in R
https://magnusdv.github.io/pedsuite/
6 stars 1 forks source link

kappaIbd() and inbred founder (grandparent-grandchild) #7

Closed hildekb closed 5 years ago

hildekb commented 5 years ago

Why are not the IBD coefficients computed for a granparent-granchild relationship where the grandparent has an inbreeding coefficient f? I was thinking that even though the founder (grandparent) is inbreed, kappa still applies and the coefficients can be computed. No error that the grandparent and grandchild are inbred occurs, but the answer is (NA,NA,NA).

library(pedtools) library(ribd)

>

> Attaching package: 'ribd'

> The following object is masked from 'package:base':

>

> kappa

x = nuclearPed(1) x = addChildren(x,father = 3)

> Mother: Creating new individual with ID = 4

founderInbreeding(x,1) = 0.1 k = kappaIbd(x,ids = c(1,5)) k

> [1] NA NA NA

magnusdv commented 5 years ago

The IBD coefficients (kappa) are defined only for non-inbred individuals. In your example the grandfather is inbred, hence all kappas involving him come out as NA. As shown below, a warning about this is printed if you add verbose = T in the call. (Perhaps this should be the default behaviour!)

BTW, the function linearPed() is useful for creating (great)grandparent relationships. Also note that pedtools is loaded automatically with ribd.

library(ribd, warn = F)
#> Loading required package: pedtools

x = linearPed(2)
founderInbreeding(x, 1) = 0.1

# Undefined kappas since 1 in inbred
kappaIbd(x, ids = c(1, 5), verbose = T)
#> Warning: kappa coefficients are only defined for non-inbred individuals.
#> 1: f = 0.100000
#> [1] NA NA NA

# All pairs at once
kappaIbd(x)
#>    id1 id2 kappa0 kappa1 kappa2
#> 1    1   2     NA     NA     NA
#> 2    1   3     NA     NA     NA
#> 3    1   4     NA     NA     NA
#> 4    1   5     NA     NA     NA
#> 5    2   3    0.0    1.0      0
#> 6    2   4    1.0    0.0      0
#> 7    2   5    0.5    0.5      0
#> 8    3   4    1.0    0.0      0
#> 9    3   5    0.0    1.0      0
#> 10   4   5    0.0    1.0      0

Created on 2019-06-14 by the reprex package (v0.3.0)