#' Copyright(c) 2017-2024 R. Mark Sharp #' This file is part of nprcgenekeepr context("addAnimalsWithNoRelative") library(testthat) examplePedigree <- nprcgenekeepr::examplePedigree ped <- qcStudbook(examplePedigree, minParentAge = 2L, reportChanges = FALSE, reportErrors = FALSE ) kmat <- kinship(ped$id, ped$sire, ped$dam, ped$gen, sparse = FALSE) currentGroups <- list(1L) currentGroups[[1L]] <- examplePedigree$id[1L:3L] candidates <- examplePedigree$id[examplePedigree$status == "ALIVE"] threshold <- 0.015625 kin <- getAnimalsWithHighKinship(kmat, ped, threshold, currentGroups, ignore = list(c("F", "F")), minAge = 1.0 ) # 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) test_that("addAnimalsWithNoRelative adds correct animals", { expect_length(kin, 2416L) expect_length(kin[["1SPLS8"]], 14L) })