Learn R Programming

nprcgenekeepr (version 3.0.0)

convertRelationships: Convert pairwise kinship values to relationship categories

Description

Part of Relations

Usage

convertRelationships(kmat, ped, ids = NULL, updateProgress = NULL)

Value

A dataframe with columns id1, id2, kinship, relation. It is a long-form table of pairwise kinships, with relationship categories included for each pair. IDs that are not in kmat are ignored. One ID gives that animal's own Self row, and no ID in kmat (or an empty ids) gives a table with no rows.

Arguments

kmat

a numeric matrix of pairwise kinship coefficients. Animal IDs are the row and column names.

ped

datatable that is the Pedigree. It contains pedigree information. The fields id, sire and dam are required.

ids

character vector of IDs or NULL to which the analysis should be restricted. If provided, only relationships between these IDs will be converted to relationships.

updateProgress

function or NULL. If this function is defined, it will be called during each iteration to update a shiny::Progress object.

Details

Ids given as numbers or as a factor, in the pedigree's id, sire and dam or in ids, are taken as their text.

Examples

Run this code
library(nprcgenekeepr)
ped <- nprcgenekeepr::smallPed
kmat <- kinship(ped$id, ped$sire, ped$dam, ped$gen, sparse = FALSE)
ids <- c("A", "B", "D", "E", "F", "G", "I", "J", "L", "M", "O", "P")
relIds <- convertRelationships(kmat, ped, ids)
rel <- convertRelationships(kmat, ped, updateProgress = function() {})
head(rel)
ped <- nprcgenekeepr::qcPed
bkmat <- kinship(ped$id, ped$sire, ped$dam, ped$gen,
  sparse = FALSE
)
relBIds <- convertRelationships(bkmat, ped, c("4LFS70", "DD1U77"))
relBIds

Run the code above in your browser using DataLab