#' Copyright(c) 2017-2024 R. Mark Sharp #' This file is part of nprcgenekeepr context("calcFE") library(testthat) ped <- data.frame( id = c("A", "B", "C", "D", "E", "F", "G"), sire = c(NA, NA, "A", "A", NA, "D", "D"), dam = c(NA, NA, "B", "B", NA, "E", "E"), stringsAsFactors = FALSE ) ped["gen"] <- findGeneration(ped$id, ped$sire, ped$dam) ped$population <- getGVPopulation(ped, NULL) pedFactors <- data.frame( id = c("A", "B", "C", "D", "E", "F", "G"), sire = c(NA, NA, "A", "A", NA, "D", "D"), dam = c(NA, NA, "B", "B", NA, "E", "E"), stringsAsFactors = TRUE ) pedFactors["gen"] <- findGeneration(pedFactors$id, pedFactors$sire, pedFactors$dam) pedFactors$population <- getGVPopulation(pedFactors, NULL) fe <- calcFE(ped) feFactors <- calcFE(pedFactors) ## Prior to forcing the pedigree to have id, sire, and dam as character vectors ## inside calcFE, the two calculations above with ped (characters) and ## feFactors (factors) resulted 2.9090 and 2.000 respectively. ## ## Used example from Analysis of Founder Representation in Pedigrees: Founder ## Equivalents and Founder Genome Equivalents. ## Zoo Biology 8:111-123, (1989) by Robert C. Lacy ## He presented 2.91 as the answer, which was not precise enough for this ## specific comparison. test_that("calcFE correctly calculates the number of founder equivalents in the pedigree", { expect_equal(fe, feFactors) expect_equal(fe, 2.9090909091) })