
Make a relation classes table from kinship pairs
Source:R/makeRelationClassesTable.R
makeRelationClassesTable.RdCounts the pairs of animals in each relationship class of a long-form kinship table.
Value
A data.frame with columns Relationship Class and
Frequency: the number of pairs in each of the following relationship
classes: Parent-Offspring, Full-Siblings, Half-Siblings,
Grandparent-Grandchild, Full-Cousins, Cousin - Other, Full-Avuncular,
Avuncular - Other, Other, and No Relation. Self pairs are not counted, and
classes with no pairs are left out.
Examples
library(nprcgenekeepr)
suppressMessages(library(dplyr))
qcPed <- nprcgenekeepr::qcPed
qcPed <- qcPed[1:50, ] # Comment out for full example
bkmat <- kinship(qcPed$id, qcPed$sire, qcPed$dam, qcPed$gen,
sparse = FALSE
)
kin <- convertRelationships(bkmat, qcPed)
relClasses <- makeRelationClassesTable(kin)
relClasses$`Relationship Class` <-
as.character(relClasses$`Relationship Class`)
relClassTbl <- kin[!kin$relation == "Self", ] |>
group_by(relation) |>
summarise(count = n())
relClassTbl
#> # A tibble: 1 × 2
#> relation count
#> <chr> <int>
#> 1 No Relation 1225