addAnimalsWithNoRelative: Adds an NA value for all animals without a relative

Description Usage Arguments Details Value Examples

View source: R/addAnimalsWithNoRelative.R

Description

This allows kin to be used with setdiff when there are no relatives otherwise an error would occur because kin[['animal_with_no_relative']] would not be found. See the following: in groupAddAssign

Usage

1
addAnimalsWithNoRelative(kin, candidates)

Arguments

kin

dataframe with kinship values

candidates

character vector of IDs of the animals available for use in the group.

Details

available[[i]] <- setdiff(available[[i]], kin[[id]])

Value

A dataframe with kinships in long form after adding a row for each animal without a relative.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
examplePedigree <- nprcgenekeepr::examplePedigree
ped <- qcStudbook(examplePedigree, minParentAge = 2, reportChanges = FALSE,
                  reportErrors = FALSE)
kmat <- kinship(ped$id, ped$sire, ped$dam, ped$gen, sparse = FALSE)
currentGroups <- list(1)
currentGroups[[1]] <- examplePedigree$id[1:3]
candidates <- examplePedigree$id[examplePedigree$status == "ALIVE"]
threshold <- 0.015625
kin <- getAnimalsWithHighKinship(kmat, ped, threshold, currentGroups,
                                 ignore = list(c("F", "F")), minAge = 1)
# Filtering out candidates related to current group members
conflicts <- unique(c(unlist(kin[unlist(currentGroups)]),
                                 unlist(currentGroups)))
candidates <- setdiff(candidates, conflicts)
kin <- addAnimalsWithNoRelative(kin, candidates)
length(kin) # should be 2416
kin[["1SPLS8"]] # should have 14 IDs

rmsharp/nprcmanager documentation built on April 24, 2021, 3:13 p.m.