
Quick Example of Simulated Kinships with Partial Parentage
nprcgenekeepr: an R Package for the Genetic Management of Colonies
R. Mark Sharp, Ph.D.
8/29/2021
Source:vignettes/simulatedKValues.Rmd
simulatedKValues.RmdIntroduction
This vignette provides a quick example of how to estimate kinship coefficients using simulation. One simulation uses 100 iterations and the other uses the same setup with 1000 simulations to illustrate the type of kinship coefficient estimate variance you can expect with a simple pedigree exhibiting partial parentage for some of the members.
Anticipation of further uses of this kinship estimation method
Retention of founder alleles is a primary driving force behind this package of utilities. This example is intentionally overly simplistic to clearly illustrate this one aspect of the methodology used with realistic pedigrees.
In this example, some of the potential parents are not members of the example pedigree and thus, by definition, have a kinship coeficient of 0.0 with all other pedigree members.
In practice most or all of the potential parents will be members of the same pedigree and will potentially have nonzero kinship coeficients with other pedigree members.
Identification of potential parents
This tutorial assumes knowledge of potential parents and does not present methods for identifying potential parents.
Planned capabilities1 will provide users the ability to fully automate the identification of potential parents. However, prior to that capability being available, users can use other methods to identify potential parents.
Creation of example pedigree2
The example is based on the following simple pedigree setup. In the pedigree given below, all of the original animals have identifiers that are single letters of the alphabet.:
Only those IDs that have unknown parents are included in the lists. For those IDs with one known parent, the known parent is included in the . See for ID . Note also that potential parents can either come from the pedigree being augmented by simulation or from outside the pedigree. See , , , and for examples of this.
Currently, if you want to provide differential weights for the different potential parents, you will need to do this directly by modifying the number of times each parent is included in the list.
Animals , , and
knitr::opts_chunk$set(echo = TRUE)
library(kableExtra) # nolint: undesirable_function_linter
library(nprcgenekeepr) # nolint: undesirable_function_linter
library(stringi) # nolint: undesirable_function_linter
ped <- nprcgenekeepr::smallPed
simParent_1 <- list( # nolint: object_name_linter
id = "A", # nolint: object_name_linter
sires = "Q",
dams = c("d1_1", "d1_2", "d1_3", "d1_4")
)
simParent_2 <- list( # nolint: object_name_linter
id = "B", # nolint: object_name_linter
sires = c("s1_1", "s1_2", "s1_3"),
dams = c("d1_1", "d1_2", "d1_3", "d1_4")
)
simParent_3 <- list( # nolint: object_name_linter
id = "E", # nolint: object_name_linter
sires = c("A", "C", "s1_1"),
dams = c("d3_1", "B")
)
simParent_4 <- list( # nolint: object_name_linter
id = "J", # nolint: object_name_linter
sires = c("A", "C", "s1_1"),
dams = c("d3_1", "B")
)
simParent_5 <- list( # nolint: object_name_linter
id = "K", # nolint: object_name_linter
sires = c("A", "C", "s1_1"),
dams = c("d3_1", "d1_2")
)
simParent_6 <- list( # nolint: object_name_linter
id = "N", # nolint: object_name_linter
sires = c("A", "C", "s1_2"),
dams = c("d3_1", "B")
)
allSimParents <- list(
simParent_1, simParent_2, simParent_3,
simParent_4, simParent_5, simParent_6
)
extractKinship <- function(simKinships, id1, id2, simulation) {
ids <- dimnames(simKinships[[simulation]])[[1L]]
simKinships[[simulation]][
seq_along(ids)[ids == id1],
seq_along(ids)[ids == id2]
]
}
extractKValue <- function(kValue, id1, id2, simulation) {
kValue[kValue$id_1 == id1 & kValue$id_2 == id2, paste0("sim_", simulation)]
}Small Example
This is the simulation. I am only printing out rows with kinship values that vary.
Before running these simulations, take time to look at the included function descriptions to see what they are expecting as arguments and what they return.
?createSimKinships
?kinshipMatricesToKValues
?extractKValue
# Only set this seed if you want to get the same simulation results each time.
set.seed(1L)
n <- 10L
simKinships <- createSimKinships(ped, allSimParents, pop = ped$id, n = n)
kValues <- kinshipMatricesToKValues(simKinships)
extractKValue(kValues, id1 = "A", id2 = "F", simulation = 1L:n)## [1] "sim_1" "sim_2" "sim_3" "sim_4" "sim_5" "sim_6" "sim_7" "sim_8"
## [9] "sim_9" "sim_10"
counts <- countKinshipValues(kValues)
counts$kinshipIds[1L:3L]## NULL
counts$kinshipValues[1L:3L]## NULL
counts$kinshipCounts[1L:3L]## NULL
stats_10 <- summarizeKinshipValues(counts)
nrow(stats_10[stats_10$sd > 0.0, ])## [1] 78
kable(stats_10[stats_10$sd > 0.0, ], longtable = TRUE) |>
kable_styling(
latex_options = c("striped", "repeat_header"),
repeat_header_method = "replace",
repeat_header_text = "\\textit{(continued)}"
)| id_1 | id_2 | min | secondQuartile | mean | median | thirdQuartile | max | sd | |
|---|---|---|---|---|---|---|---|---|---|
| 5 | A | E | 0.00000 | 0.00000 | 0.075000 | 0.000000 | 0.25000 | 0.25000 | 0.1207615 |
| 6 | A | F | 0.12500 | 0.12500 | 0.162500 | 0.125000 | 0.25000 | 0.25000 | 0.0603807 |
| 7 | A | G | 0.12500 | 0.12500 | 0.162500 | 0.125000 | 0.25000 | 0.25000 | 0.0603807 |
| 9 | A | I | 0.25000 | 0.25000 | 0.312500 | 0.312500 | 0.37500 | 0.37500 | 0.0658808 |
| 10 | A | J | 0.00000 | 0.00000 | 0.125000 | 0.125000 | 0.25000 | 0.25000 | 0.1317616 |
| 14 | A | N | 0.00000 | 0.00000 | 0.050000 | 0.000000 | 0.00000 | 0.25000 | 0.1054093 |
| 21 | B | E | 0.00000 | 0.00000 | 0.150000 | 0.250000 | 0.25000 | 0.25000 | 0.1290994 |
| 22 | B | F | 0.12500 | 0.12500 | 0.200000 | 0.250000 | 0.25000 | 0.25000 | 0.0645497 |
| 23 | B | G | 0.12500 | 0.12500 | 0.200000 | 0.250000 | 0.25000 | 0.25000 | 0.0645497 |
| 25 | B | I | 0.00000 | 0.00000 | 0.075000 | 0.125000 | 0.12500 | 0.12500 | 0.0645497 |
| 26 | B | J | 0.00000 | 0.00000 | 0.150000 | 0.250000 | 0.25000 | 0.25000 | 0.1290994 |
| 30 | B | N | 0.00000 | 0.00000 | 0.050000 | 0.000000 | 0.00000 | 0.25000 | 0.1054093 |
| 36 | C | E | 0.00000 | 0.00000 | 0.112500 | 0.125000 | 0.12500 | 0.25000 | 0.0922331 |
| 37 | C | F | 0.12500 | 0.12500 | 0.181250 | 0.187500 | 0.18750 | 0.25000 | 0.0461165 |
| 38 | C | G | 0.12500 | 0.12500 | 0.181250 | 0.187500 | 0.18750 | 0.25000 | 0.0461165 |
| 40 | C | I | 0.12500 | 0.18750 | 0.193750 | 0.187500 | 0.18750 | 0.25000 | 0.0354779 |
| 41 | C | J | 0.00000 | 0.12500 | 0.137500 | 0.125000 | 0.12500 | 0.25000 | 0.0709558 |
| 45 | C | N | 0.00000 | 0.00000 | 0.050000 | 0.000000 | 0.12500 | 0.25000 | 0.0874007 |
| 50 | D | E | 0.00000 | 0.00000 | 0.112500 | 0.125000 | 0.12500 | 0.25000 | 0.0922331 |
| 51 | D | F | 0.25000 | 0.25000 | 0.306250 | 0.312500 | 0.31250 | 0.37500 | 0.0461165 |
| 52 | D | G | 0.25000 | 0.25000 | 0.306250 | 0.312500 | 0.31250 | 0.37500 | 0.0461165 |
| 54 | D | I | 0.12500 | 0.18750 | 0.193750 | 0.187500 | 0.18750 | 0.25000 | 0.0354779 |
| 55 | D | J | 0.00000 | 0.12500 | 0.137500 | 0.125000 | 0.12500 | 0.25000 | 0.0709558 |
| 59 | D | N | 0.00000 | 0.00000 | 0.050000 | 0.000000 | 0.12500 | 0.25000 | 0.0874007 |
| 64 | E | F | 0.25000 | 0.25000 | 0.306250 | 0.312500 | 0.31250 | 0.37500 | 0.0461165 |
| 65 | E | G | 0.25000 | 0.25000 | 0.306250 | 0.312500 | 0.31250 | 0.37500 | 0.0461165 |
| 66 | E | H | 0.00000 | 0.00000 | 0.112500 | 0.125000 | 0.12500 | 0.25000 | 0.0922331 |
| 67 | E | I | 0.00000 | 0.00000 | 0.087500 | 0.062500 | 0.18750 | 0.18750 | 0.0790569 |
| 68 | E | J | 0.00000 | 0.00000 | 0.100000 | 0.125000 | 0.12500 | 0.25000 | 0.0790569 |
| 69 | E | K | 0.00000 | 0.00000 | 0.062500 | 0.062500 | 0.12500 | 0.12500 | 0.0658808 |
| 70 | E | L | 0.06250 | 0.06250 | 0.087500 | 0.062500 | 0.12500 | 0.12500 | 0.0322749 |
| 71 | E | M | 0.00000 | 0.00000 | 0.037500 | 0.000000 | 0.12500 | 0.12500 | 0.0603807 |
| 72 | E | N | 0.00000 | 0.00000 | 0.037500 | 0.000000 | 0.12500 | 0.12500 | 0.0603807 |
| 74 | E | P | 0.00000 | 0.00000 | 0.018750 | 0.000000 | 0.06250 | 0.06250 | 0.0301904 |
| 75 | E | Q | 0.00000 | 0.00000 | 0.037500 | 0.000000 | 0.12500 | 0.12500 | 0.0603807 |
| 76 | F | F | 0.50000 | 0.50000 | 0.556250 | 0.562500 | 0.56250 | 0.62500 | 0.0461165 |
| 77 | F | G | 0.25000 | 0.25000 | 0.306250 | 0.312500 | 0.31250 | 0.37500 | 0.0461165 |
| 78 | F | H | 0.12500 | 0.12500 | 0.181250 | 0.187500 | 0.18750 | 0.25000 | 0.0461165 |
| 79 | F | I | 0.06250 | 0.12500 | 0.140625 | 0.140625 | 0.18750 | 0.18750 | 0.0423127 |
| 80 | F | J | 0.00000 | 0.12500 | 0.118750 | 0.125000 | 0.12500 | 0.18750 | 0.0547247 |
| 81 | F | K | 0.00000 | 0.00000 | 0.031250 | 0.031250 | 0.06250 | 0.06250 | 0.0329404 |
| 82 | F | L | 0.09375 | 0.09375 | 0.106250 | 0.093750 | 0.12500 | 0.12500 | 0.0161374 |
| 83 | F | M | 0.06250 | 0.06250 | 0.081250 | 0.062500 | 0.12500 | 0.12500 | 0.0301904 |
| 84 | F | N | 0.00000 | 0.00000 | 0.043750 | 0.000000 | 0.12500 | 0.12500 | 0.0592927 |
| 86 | F | P | 0.03125 | 0.03125 | 0.040625 | 0.031250 | 0.06250 | 0.06250 | 0.0150952 |
| 87 | F | Q | 0.06250 | 0.06250 | 0.081250 | 0.062500 | 0.12500 | 0.12500 | 0.0301904 |
| 88 | G | G | 0.50000 | 0.50000 | 0.556250 | 0.562500 | 0.56250 | 0.62500 | 0.0461165 |
| 89 | G | H | 0.12500 | 0.12500 | 0.181250 | 0.187500 | 0.18750 | 0.25000 | 0.0461165 |
| 90 | G | I | 0.06250 | 0.12500 | 0.140625 | 0.140625 | 0.18750 | 0.18750 | 0.0423127 |
| 91 | G | J | 0.00000 | 0.12500 | 0.118750 | 0.125000 | 0.12500 | 0.18750 | 0.0547247 |
| 92 | G | K | 0.00000 | 0.00000 | 0.031250 | 0.031250 | 0.06250 | 0.06250 | 0.0329404 |
| 93 | G | L | 0.09375 | 0.09375 | 0.106250 | 0.093750 | 0.12500 | 0.12500 | 0.0161374 |
| 94 | G | M | 0.06250 | 0.06250 | 0.081250 | 0.062500 | 0.12500 | 0.12500 | 0.0301904 |
| 95 | G | N | 0.00000 | 0.00000 | 0.043750 | 0.000000 | 0.12500 | 0.12500 | 0.0592927 |
| 97 | G | P | 0.03125 | 0.03125 | 0.040625 | 0.031250 | 0.06250 | 0.06250 | 0.0150952 |
| 98 | G | Q | 0.06250 | 0.06250 | 0.081250 | 0.062500 | 0.12500 | 0.12500 | 0.0301904 |
| 100 | H | I | 0.12500 | 0.18750 | 0.193750 | 0.187500 | 0.18750 | 0.25000 | 0.0354779 |
| 101 | H | J | 0.00000 | 0.12500 | 0.137500 | 0.125000 | 0.12500 | 0.25000 | 0.0709558 |
| 105 | H | N | 0.00000 | 0.00000 | 0.050000 | 0.000000 | 0.12500 | 0.25000 | 0.0874007 |
| 109 | I | I | 0.50000 | 0.50000 | 0.562500 | 0.562500 | 0.62500 | 0.62500 | 0.0658808 |
| 110 | I | J | 0.25000 | 0.25000 | 0.312500 | 0.312500 | 0.37500 | 0.37500 | 0.0658808 |
| 111 | I | K | 0.00000 | 0.00000 | 0.006250 | 0.000000 | 0.00000 | 0.06250 | 0.0197642 |
| 112 | I | L | 0.06250 | 0.09375 | 0.100000 | 0.093750 | 0.12500 | 0.12500 | 0.0197642 |
| 113 | I | M | 0.12500 | 0.12500 | 0.156250 | 0.156250 | 0.18750 | 0.18750 | 0.0329404 |
| 114 | I | N | 0.00000 | 0.00000 | 0.056250 | 0.000000 | 0.12500 | 0.25000 | 0.0952427 |
| 116 | I | P | 0.06250 | 0.06250 | 0.078125 | 0.078125 | 0.09375 | 0.09375 | 0.0164702 |
| 117 | I | Q | 0.12500 | 0.12500 | 0.156250 | 0.156250 | 0.18750 | 0.18750 | 0.0329404 |
| 119 | J | K | 0.00000 | 0.00000 | 0.012500 | 0.000000 | 0.00000 | 0.12500 | 0.0395285 |
| 120 | J | L | 0.00000 | 0.06250 | 0.075000 | 0.062500 | 0.12500 | 0.12500 | 0.0395285 |
| 121 | J | M | 0.00000 | 0.00000 | 0.062500 | 0.062500 | 0.12500 | 0.12500 | 0.0658808 |
| 122 | J | N | 0.00000 | 0.00000 | 0.062500 | 0.000000 | 0.12500 | 0.25000 | 0.1062296 |
| 124 | J | P | 0.00000 | 0.00000 | 0.031250 | 0.031250 | 0.06250 | 0.06250 | 0.0329404 |
| 125 | J | Q | 0.00000 | 0.00000 | 0.062500 | 0.062500 | 0.12500 | 0.12500 | 0.0658808 |
| 129 | K | N | 0.00000 | 0.00000 | 0.025000 | 0.000000 | 0.00000 | 0.12500 | 0.0527046 |
| 135 | L | N | 0.00000 | 0.00000 | 0.037500 | 0.000000 | 0.06250 | 0.12500 | 0.0527046 |
| 140 | M | N | 0.00000 | 0.00000 | 0.025000 | 0.000000 | 0.00000 | 0.12500 | 0.0527046 |
| 146 | N | P | 0.00000 | 0.00000 | 0.012500 | 0.000000 | 0.00000 | 0.06250 | 0.0263523 |
| 147 | N | Q | 0.00000 | 0.00000 | 0.025000 | 0.000000 | 0.00000 | 0.12500 | 0.0527046 |
A larger simulation
set.seed(1L)
n <- 100L
simKinships <- createSimKinships(ped, allSimParents, pop = ped$id, n = n)
kValues <- kinshipMatricesToKValues(simKinships)
extractKValue(kValues, id1 = "A", id2 = "F", simulation = 1L:10L)## [1] "sim_1" "sim_2" "sim_3" "sim_4" "sim_5" "sim_6" "sim_7" "sim_8"
## [9] "sim_9" "sim_10"
counts <- countKinshipValues(kValues)
counts$kinshipIds[1L:3L]## NULL
counts$kinshipValues[1L:3L]## NULL
counts$kinshipCounts[1L:3L]## NULL
stats_100 <- summarizeKinshipValues(counts)
nrow(stats_100[stats_100$sd > 0.0, ])## [1] 94
kable(stats_100[stats_100$sd > 0.0, ], longtable = TRUE) |>
kable_styling(
latex_options = c("striped", "repeat_header"),
repeat_header_method = "replace",
repeat_header_text = "\\textit{(continued)}"
)| id_1 | id_2 | min | secondQuartile | mean | median | thirdQuartile | max | sd | |
|---|---|---|---|---|---|---|---|---|---|
| 5 | A | E | 0.00000 | 0.00000 | 0.0825000 | 0.00000 | 0.25000 | 0.25000 | 0.1181454 |
| 6 | A | F | 0.12500 | 0.12500 | 0.1662500 | 0.12500 | 0.25000 | 0.25000 | 0.0590727 |
| 7 | A | G | 0.12500 | 0.12500 | 0.1662500 | 0.12500 | 0.25000 | 0.25000 | 0.0590727 |
| 9 | A | I | 0.25000 | 0.25000 | 0.2987500 | 0.25000 | 0.37500 | 0.37500 | 0.0612759 |
| 10 | A | J | 0.00000 | 0.00000 | 0.0975000 | 0.00000 | 0.25000 | 0.25000 | 0.1225518 |
| 11 | A | K | 0.00000 | 0.00000 | 0.0700000 | 0.00000 | 0.25000 | 0.25000 | 0.1128152 |
| 12 | A | L | 0.12500 | 0.12500 | 0.1600000 | 0.12500 | 0.25000 | 0.25000 | 0.0564076 |
| 14 | A | N | 0.00000 | 0.00000 | 0.0800000 | 0.00000 | 0.25000 | 0.25000 | 0.1172065 |
| 21 | B | E | 0.00000 | 0.00000 | 0.1325000 | 0.25000 | 0.25000 | 0.25000 | 0.1254034 |
| 22 | B | F | 0.12500 | 0.12500 | 0.1912500 | 0.25000 | 0.25000 | 0.25000 | 0.0627017 |
| 23 | B | G | 0.12500 | 0.12500 | 0.1912500 | 0.25000 | 0.25000 | 0.25000 | 0.0627017 |
| 25 | B | I | 0.00000 | 0.00000 | 0.0625000 | 0.06250 | 0.12500 | 0.12500 | 0.0628149 |
| 26 | B | J | 0.00000 | 0.00000 | 0.1250000 | 0.12500 | 0.25000 | 0.25000 | 0.1256297 |
| 30 | B | N | 0.00000 | 0.00000 | 0.1100000 | 0.00000 | 0.25000 | 0.25000 | 0.1247219 |
| 36 | C | E | 0.00000 | 0.00000 | 0.1075000 | 0.12500 | 0.12500 | 0.25000 | 0.0870751 |
| 37 | C | F | 0.12500 | 0.12500 | 0.1787500 | 0.18750 | 0.18750 | 0.25000 | 0.0435375 |
| 38 | C | G | 0.12500 | 0.12500 | 0.1787500 | 0.18750 | 0.18750 | 0.25000 | 0.0435375 |
| 40 | C | I | 0.12500 | 0.15625 | 0.1806250 | 0.18750 | 0.18750 | 0.25000 | 0.0386145 |
| 41 | C | J | 0.00000 | 0.06250 | 0.1112500 | 0.12500 | 0.12500 | 0.25000 | 0.0772291 |
| 42 | C | K | 0.00000 | 0.00000 | 0.0350000 | 0.00000 | 0.12500 | 0.12500 | 0.0564076 |
| 43 | C | L | 0.25000 | 0.25000 | 0.2675000 | 0.25000 | 0.31250 | 0.31250 | 0.0282038 |
| 45 | C | N | 0.00000 | 0.00000 | 0.0950000 | 0.12500 | 0.12500 | 0.25000 | 0.0925235 |
| 50 | D | E | 0.00000 | 0.00000 | 0.1075000 | 0.12500 | 0.12500 | 0.25000 | 0.0870751 |
| 51 | D | F | 0.25000 | 0.25000 | 0.3037500 | 0.31250 | 0.31250 | 0.37500 | 0.0435375 |
| 52 | D | G | 0.25000 | 0.25000 | 0.3037500 | 0.31250 | 0.31250 | 0.37500 | 0.0435375 |
| 54 | D | I | 0.12500 | 0.15625 | 0.1806250 | 0.18750 | 0.18750 | 0.25000 | 0.0386145 |
| 55 | D | J | 0.00000 | 0.06250 | 0.1112500 | 0.12500 | 0.12500 | 0.25000 | 0.0772291 |
| 56 | D | K | 0.00000 | 0.00000 | 0.0350000 | 0.00000 | 0.12500 | 0.12500 | 0.0564076 |
| 57 | D | L | 0.12500 | 0.12500 | 0.1425000 | 0.12500 | 0.18750 | 0.18750 | 0.0282038 |
| 59 | D | N | 0.00000 | 0.00000 | 0.0950000 | 0.12500 | 0.12500 | 0.25000 | 0.0925235 |
| 64 | E | F | 0.25000 | 0.25000 | 0.3037500 | 0.31250 | 0.31250 | 0.37500 | 0.0435375 |
| 65 | E | G | 0.25000 | 0.25000 | 0.3037500 | 0.31250 | 0.31250 | 0.37500 | 0.0435375 |
| 66 | E | H | 0.00000 | 0.00000 | 0.1075000 | 0.12500 | 0.12500 | 0.25000 | 0.0870751 |
| 67 | E | I | 0.00000 | 0.00000 | 0.0762500 | 0.06250 | 0.12500 | 0.25000 | 0.0730275 |
| 68 | E | J | 0.00000 | 0.00000 | 0.0700000 | 0.00000 | 0.12500 | 0.25000 | 0.0800883 |
| 69 | E | K | 0.00000 | 0.00000 | 0.0387500 | 0.00000 | 0.12500 | 0.12500 | 0.0581029 |
| 70 | E | L | 0.00000 | 0.06250 | 0.0731250 | 0.06250 | 0.12500 | 0.18750 | 0.0533409 |
| 71 | E | M | 0.00000 | 0.00000 | 0.0412500 | 0.00000 | 0.12500 | 0.12500 | 0.0590727 |
| 72 | E | N | 0.00000 | 0.00000 | 0.0625000 | 0.00000 | 0.12500 | 0.25000 | 0.0743235 |
| 74 | E | P | 0.00000 | 0.00000 | 0.0206250 | 0.00000 | 0.06250 | 0.06250 | 0.0295363 |
| 75 | E | Q | 0.00000 | 0.00000 | 0.0412500 | 0.00000 | 0.12500 | 0.12500 | 0.0590727 |
| 76 | F | F | 0.50000 | 0.50000 | 0.5537500 | 0.56250 | 0.56250 | 0.62500 | 0.0435375 |
| 77 | F | G | 0.25000 | 0.25000 | 0.3037500 | 0.31250 | 0.31250 | 0.37500 | 0.0435375 |
| 78 | F | H | 0.12500 | 0.12500 | 0.1787500 | 0.18750 | 0.18750 | 0.25000 | 0.0435375 |
| 79 | F | I | 0.06250 | 0.09375 | 0.1284375 | 0.12500 | 0.15625 | 0.25000 | 0.0425788 |
| 80 | F | J | 0.00000 | 0.06250 | 0.0906250 | 0.06250 | 0.12500 | 0.25000 | 0.0636727 |
| 81 | F | K | 0.00000 | 0.00000 | 0.0368750 | 0.00000 | 0.06250 | 0.12500 | 0.0436055 |
| 82 | F | L | 0.06250 | 0.09375 | 0.1078125 | 0.09375 | 0.12500 | 0.18750 | 0.0321447 |
| 83 | F | M | 0.06250 | 0.06250 | 0.0831250 | 0.06250 | 0.12500 | 0.12500 | 0.0295363 |
| 84 | F | N | 0.00000 | 0.00000 | 0.0787500 | 0.06250 | 0.12500 | 0.25000 | 0.0719607 |
| 86 | F | P | 0.03125 | 0.03125 | 0.0415625 | 0.03125 | 0.06250 | 0.06250 | 0.0147682 |
| 87 | F | Q | 0.06250 | 0.06250 | 0.0831250 | 0.06250 | 0.12500 | 0.12500 | 0.0295363 |
| 88 | G | G | 0.50000 | 0.50000 | 0.5537500 | 0.56250 | 0.56250 | 0.62500 | 0.0435375 |
| 89 | G | H | 0.12500 | 0.12500 | 0.1787500 | 0.18750 | 0.18750 | 0.25000 | 0.0435375 |
| 90 | G | I | 0.06250 | 0.09375 | 0.1284375 | 0.12500 | 0.15625 | 0.25000 | 0.0425788 |
| 91 | G | J | 0.00000 | 0.06250 | 0.0906250 | 0.06250 | 0.12500 | 0.25000 | 0.0636727 |
| 92 | G | K | 0.00000 | 0.00000 | 0.0368750 | 0.00000 | 0.06250 | 0.12500 | 0.0436055 |
| 93 | G | L | 0.06250 | 0.09375 | 0.1078125 | 0.09375 | 0.12500 | 0.18750 | 0.0321447 |
| 94 | G | M | 0.06250 | 0.06250 | 0.0831250 | 0.06250 | 0.12500 | 0.12500 | 0.0295363 |
| 95 | G | N | 0.00000 | 0.00000 | 0.0787500 | 0.06250 | 0.12500 | 0.25000 | 0.0719607 |
| 97 | G | P | 0.03125 | 0.03125 | 0.0415625 | 0.03125 | 0.06250 | 0.06250 | 0.0147682 |
| 98 | G | Q | 0.06250 | 0.06250 | 0.0831250 | 0.06250 | 0.12500 | 0.12500 | 0.0295363 |
| 100 | H | I | 0.12500 | 0.15625 | 0.1806250 | 0.18750 | 0.18750 | 0.25000 | 0.0386145 |
| 101 | H | J | 0.00000 | 0.06250 | 0.1112500 | 0.12500 | 0.12500 | 0.25000 | 0.0772291 |
| 102 | H | K | 0.00000 | 0.00000 | 0.0350000 | 0.00000 | 0.12500 | 0.12500 | 0.0564076 |
| 103 | H | L | 0.12500 | 0.12500 | 0.1425000 | 0.12500 | 0.18750 | 0.18750 | 0.0282038 |
| 105 | H | N | 0.00000 | 0.00000 | 0.0950000 | 0.12500 | 0.12500 | 0.25000 | 0.0925235 |
| 109 | I | I | 0.50000 | 0.50000 | 0.5487500 | 0.50000 | 0.62500 | 0.62500 | 0.0612759 |
| 110 | I | J | 0.25000 | 0.25000 | 0.2987500 | 0.25000 | 0.37500 | 0.37500 | 0.0612759 |
| 111 | I | K | 0.00000 | 0.00000 | 0.0468750 | 0.00000 | 0.12500 | 0.18750 | 0.0649002 |
| 112 | I | L | 0.06250 | 0.09375 | 0.1137500 | 0.09375 | 0.12500 | 0.21875 | 0.0359529 |
| 113 | I | M | 0.12500 | 0.12500 | 0.1493750 | 0.12500 | 0.18750 | 0.18750 | 0.0306379 |
| 114 | I | N | 0.00000 | 0.00000 | 0.0637500 | 0.00000 | 0.12500 | 0.25000 | 0.0794453 |
| 116 | I | P | 0.06250 | 0.06250 | 0.0746875 | 0.06250 | 0.09375 | 0.09375 | 0.0153190 |
| 117 | I | Q | 0.12500 | 0.12500 | 0.1493750 | 0.12500 | 0.18750 | 0.18750 | 0.0306379 |
| 119 | J | K | 0.00000 | 0.00000 | 0.0237500 | 0.00000 | 0.00000 | 0.12500 | 0.0492847 |
| 120 | J | L | 0.00000 | 0.06250 | 0.0675000 | 0.06250 | 0.12500 | 0.18750 | 0.0467370 |
| 121 | J | M | 0.00000 | 0.00000 | 0.0487500 | 0.00000 | 0.12500 | 0.12500 | 0.0612759 |
| 122 | J | N | 0.00000 | 0.00000 | 0.0475000 | 0.00000 | 0.12500 | 0.25000 | 0.0727785 |
| 124 | J | P | 0.00000 | 0.00000 | 0.0243750 | 0.00000 | 0.06250 | 0.06250 | 0.0306379 |
| 125 | J | Q | 0.00000 | 0.00000 | 0.0487500 | 0.00000 | 0.12500 | 0.12500 | 0.0612759 |
| 127 | K | L | 0.25000 | 0.25000 | 0.2675000 | 0.25000 | 0.31250 | 0.31250 | 0.0282038 |
| 128 | K | M | 0.00000 | 0.00000 | 0.0350000 | 0.00000 | 0.12500 | 0.12500 | 0.0564076 |
| 129 | K | N | 0.00000 | 0.00000 | 0.0287500 | 0.00000 | 0.00000 | 0.12500 | 0.0528691 |
| 131 | K | P | 0.00000 | 0.00000 | 0.0175000 | 0.00000 | 0.06250 | 0.06250 | 0.0282038 |
| 132 | K | Q | 0.00000 | 0.00000 | 0.0350000 | 0.00000 | 0.12500 | 0.12500 | 0.0564076 |
| 133 | L | L | 0.50000 | 0.50000 | 0.5175000 | 0.50000 | 0.56250 | 0.56250 | 0.0282038 |
| 134 | L | M | 0.06250 | 0.06250 | 0.0800000 | 0.06250 | 0.12500 | 0.12500 | 0.0282038 |
| 135 | L | N | 0.00000 | 0.00000 | 0.0618750 | 0.06250 | 0.12500 | 0.18750 | 0.0536654 |
| 137 | L | P | 0.03125 | 0.03125 | 0.0400000 | 0.03125 | 0.06250 | 0.06250 | 0.0141019 |
| 138 | L | Q | 0.06250 | 0.06250 | 0.0800000 | 0.06250 | 0.12500 | 0.12500 | 0.0282038 |
| 140 | M | N | 0.00000 | 0.00000 | 0.0400000 | 0.00000 | 0.12500 | 0.12500 | 0.0586033 |
| 146 | N | P | 0.00000 | 0.00000 | 0.0200000 | 0.00000 | 0.06250 | 0.06250 | 0.0293016 |
| 147 | N | Q | 0.00000 | 0.00000 | 0.0400000 | 0.00000 | 0.12500 | 0.12500 | 0.0586033 |
A much larger simulation
set.seed(1L)
n <- 1000L
simKinships <- createSimKinships(ped, allSimParents, pop = ped$id, n = n)
kValues <- kinshipMatricesToKValues(simKinships)
extractKValue(kValues, id1 = "A", id2 = "F", simulation = 1L:10L)## [1] "sim_1" "sim_2" "sim_3" "sim_4" "sim_5" "sim_6" "sim_7" "sim_8"
## [9] "sim_9" "sim_10"
counts <- countKinshipValues(kValues)
counts$kinshipIds[1L:3L]## NULL
counts$kinshipValues[1L:3L]## NULL
counts$kinshipCounts[1L:3L]## NULL
stats_1000 <- summarizeKinshipValues(counts)
nrow(stats_1000[stats_1000$sd > 0.0, ])## [1] 94
kable(stats_1000[stats_1000$sd > 0.0, ], longtable = TRUE) |>
kable_styling(
latex_options = c("striped", "repeat_header"),
repeat_header_method = "replace",
repeat_header_text = "\\textit{(continued)}"
)| id_1 | id_2 | min | secondQuartile | mean | median | thirdQuartile | max | sd | |
|---|---|---|---|---|---|---|---|---|---|
| 5 | A | E | 0.00000 | 0.00000 | 0.0840000 | 0.00000 | 0.25000 | 0.25000 | 0.1181438 |
| 6 | A | F | 0.12500 | 0.12500 | 0.1670000 | 0.12500 | 0.25000 | 0.25000 | 0.0590719 |
| 7 | A | G | 0.12500 | 0.12500 | 0.1670000 | 0.12500 | 0.25000 | 0.25000 | 0.0590719 |
| 9 | A | I | 0.25000 | 0.25000 | 0.2937500 | 0.25000 | 0.37500 | 0.37500 | 0.0596510 |
| 10 | A | J | 0.00000 | 0.00000 | 0.0875000 | 0.00000 | 0.25000 | 0.25000 | 0.1193021 |
| 11 | A | K | 0.00000 | 0.00000 | 0.0817500 | 0.00000 | 0.25000 | 0.25000 | 0.1173380 |
| 12 | A | L | 0.12500 | 0.12500 | 0.1658750 | 0.12500 | 0.25000 | 0.25000 | 0.0586690 |
| 14 | A | N | 0.00000 | 0.00000 | 0.0810000 | 0.00000 | 0.25000 | 0.25000 | 0.1170585 |
| 21 | B | E | 0.00000 | 0.00000 | 0.1250000 | 0.12500 | 0.25000 | 0.25000 | 0.1250625 |
| 22 | B | F | 0.12500 | 0.12500 | 0.1875000 | 0.18750 | 0.25000 | 0.25000 | 0.0625313 |
| 23 | B | G | 0.12500 | 0.12500 | 0.1875000 | 0.18750 | 0.25000 | 0.25000 | 0.0625313 |
| 25 | B | I | 0.00000 | 0.00000 | 0.0586250 | 0.00000 | 0.12500 | 0.12500 | 0.0624110 |
| 26 | B | J | 0.00000 | 0.00000 | 0.1172500 | 0.00000 | 0.25000 | 0.25000 | 0.1248219 |
| 30 | B | N | 0.00000 | 0.00000 | 0.1217500 | 0.00000 | 0.25000 | 0.25000 | 0.1250203 |
| 36 | C | E | 0.00000 | 0.00000 | 0.1045000 | 0.12500 | 0.12500 | 0.25000 | 0.0852908 |
| 37 | C | F | 0.12500 | 0.12500 | 0.1772500 | 0.18750 | 0.18750 | 0.25000 | 0.0426454 |
| 38 | C | G | 0.12500 | 0.12500 | 0.1772500 | 0.18750 | 0.18750 | 0.25000 | 0.0426454 |
| 40 | C | I | 0.12500 | 0.12500 | 0.1761875 | 0.18750 | 0.18750 | 0.25000 | 0.0420515 |
| 41 | C | J | 0.00000 | 0.00000 | 0.1023750 | 0.12500 | 0.12500 | 0.25000 | 0.0841030 |
| 42 | C | K | 0.00000 | 0.00000 | 0.0408750 | 0.00000 | 0.12500 | 0.12500 | 0.0586690 |
| 43 | C | L | 0.25000 | 0.25000 | 0.2704375 | 0.25000 | 0.31250 | 0.31250 | 0.0293345 |
| 45 | C | N | 0.00000 | 0.00000 | 0.1013750 | 0.12500 | 0.12500 | 0.25000 | 0.0878362 |
| 50 | D | E | 0.00000 | 0.00000 | 0.1045000 | 0.12500 | 0.12500 | 0.25000 | 0.0852908 |
| 51 | D | F | 0.25000 | 0.25000 | 0.3022500 | 0.31250 | 0.31250 | 0.37500 | 0.0426454 |
| 52 | D | G | 0.25000 | 0.25000 | 0.3022500 | 0.31250 | 0.31250 | 0.37500 | 0.0426454 |
| 54 | D | I | 0.12500 | 0.12500 | 0.1761875 | 0.18750 | 0.18750 | 0.25000 | 0.0420515 |
| 55 | D | J | 0.00000 | 0.00000 | 0.1023750 | 0.12500 | 0.12500 | 0.25000 | 0.0841030 |
| 56 | D | K | 0.00000 | 0.00000 | 0.0408750 | 0.00000 | 0.12500 | 0.12500 | 0.0586690 |
| 57 | D | L | 0.12500 | 0.12500 | 0.1454375 | 0.12500 | 0.18750 | 0.18750 | 0.0293345 |
| 59 | D | N | 0.00000 | 0.00000 | 0.1013750 | 0.12500 | 0.12500 | 0.25000 | 0.0878362 |
| 64 | E | F | 0.25000 | 0.25000 | 0.3022500 | 0.31250 | 0.31250 | 0.37500 | 0.0426454 |
| 65 | E | G | 0.25000 | 0.25000 | 0.3022500 | 0.31250 | 0.31250 | 0.37500 | 0.0426454 |
| 66 | E | H | 0.00000 | 0.00000 | 0.1045000 | 0.12500 | 0.12500 | 0.25000 | 0.0852908 |
| 67 | E | I | 0.00000 | 0.00000 | 0.0713125 | 0.06250 | 0.12500 | 0.25000 | 0.0740704 |
| 68 | E | J | 0.00000 | 0.00000 | 0.0586250 | 0.00000 | 0.12500 | 0.25000 | 0.0747283 |
| 69 | E | K | 0.00000 | 0.00000 | 0.0276250 | 0.00000 | 0.00000 | 0.12500 | 0.0518910 |
| 70 | E | L | 0.00000 | 0.00000 | 0.0660625 | 0.06250 | 0.12500 | 0.18750 | 0.0532710 |
| 71 | E | M | 0.00000 | 0.00000 | 0.0420000 | 0.00000 | 0.12500 | 0.12500 | 0.0590719 |
| 72 | E | N | 0.00000 | 0.00000 | 0.0565000 | 0.00000 | 0.12500 | 0.25000 | 0.0722442 |
| 74 | E | P | 0.00000 | 0.00000 | 0.0210000 | 0.00000 | 0.06250 | 0.06250 | 0.0295360 |
| 75 | E | Q | 0.00000 | 0.00000 | 0.0420000 | 0.00000 | 0.12500 | 0.12500 | 0.0590719 |
| 76 | F | F | 0.50000 | 0.50000 | 0.5522500 | 0.56250 | 0.56250 | 0.62500 | 0.0426454 |
| 77 | F | G | 0.25000 | 0.25000 | 0.3022500 | 0.31250 | 0.31250 | 0.37500 | 0.0426454 |
| 78 | F | H | 0.12500 | 0.12500 | 0.1772500 | 0.18750 | 0.18750 | 0.25000 | 0.0426454 |
| 79 | F | I | 0.06250 | 0.09375 | 0.1237500 | 0.12500 | 0.15625 | 0.25000 | 0.0462731 |
| 80 | F | J | 0.00000 | 0.00000 | 0.0805000 | 0.06250 | 0.12500 | 0.25000 | 0.0659714 |
| 81 | F | K | 0.00000 | 0.00000 | 0.0342500 | 0.00000 | 0.06250 | 0.12500 | 0.0434894 |
| 82 | F | L | 0.06250 | 0.09375 | 0.1057500 | 0.09375 | 0.12500 | 0.18750 | 0.0319238 |
| 83 | F | M | 0.06250 | 0.06250 | 0.0835000 | 0.06250 | 0.12500 | 0.12500 | 0.0295360 |
| 84 | F | N | 0.00000 | 0.00000 | 0.0789375 | 0.06250 | 0.12500 | 0.25000 | 0.0664667 |
| 86 | F | P | 0.03125 | 0.03125 | 0.0417500 | 0.03125 | 0.06250 | 0.06250 | 0.0147680 |
| 87 | F | Q | 0.06250 | 0.06250 | 0.0835000 | 0.06250 | 0.12500 | 0.12500 | 0.0295360 |
| 88 | G | G | 0.50000 | 0.50000 | 0.5522500 | 0.56250 | 0.56250 | 0.62500 | 0.0426454 |
| 89 | G | H | 0.12500 | 0.12500 | 0.1772500 | 0.18750 | 0.18750 | 0.25000 | 0.0426454 |
| 90 | G | I | 0.06250 | 0.09375 | 0.1237500 | 0.12500 | 0.15625 | 0.25000 | 0.0462731 |
| 91 | G | J | 0.00000 | 0.00000 | 0.0805000 | 0.06250 | 0.12500 | 0.25000 | 0.0659714 |
| 92 | G | K | 0.00000 | 0.00000 | 0.0342500 | 0.00000 | 0.06250 | 0.12500 | 0.0434894 |
| 93 | G | L | 0.06250 | 0.09375 | 0.1057500 | 0.09375 | 0.12500 | 0.18750 | 0.0319238 |
| 94 | G | M | 0.06250 | 0.06250 | 0.0835000 | 0.06250 | 0.12500 | 0.12500 | 0.0295360 |
| 95 | G | N | 0.00000 | 0.00000 | 0.0789375 | 0.06250 | 0.12500 | 0.25000 | 0.0664667 |
| 97 | G | P | 0.03125 | 0.03125 | 0.0417500 | 0.03125 | 0.06250 | 0.06250 | 0.0147680 |
| 98 | G | Q | 0.06250 | 0.06250 | 0.0835000 | 0.06250 | 0.12500 | 0.12500 | 0.0295360 |
| 100 | H | I | 0.12500 | 0.12500 | 0.1761875 | 0.18750 | 0.18750 | 0.25000 | 0.0420515 |
| 101 | H | J | 0.00000 | 0.00000 | 0.1023750 | 0.12500 | 0.12500 | 0.25000 | 0.0841030 |
| 102 | H | K | 0.00000 | 0.00000 | 0.0408750 | 0.00000 | 0.12500 | 0.12500 | 0.0586690 |
| 103 | H | L | 0.12500 | 0.12500 | 0.1454375 | 0.12500 | 0.18750 | 0.18750 | 0.0293345 |
| 105 | H | N | 0.00000 | 0.00000 | 0.1013750 | 0.12500 | 0.12500 | 0.25000 | 0.0878362 |
| 109 | I | I | 0.50000 | 0.50000 | 0.5437500 | 0.50000 | 0.62500 | 0.62500 | 0.0596510 |
| 110 | I | J | 0.25000 | 0.25000 | 0.2937500 | 0.25000 | 0.37500 | 0.37500 | 0.0596510 |
| 111 | I | K | 0.00000 | 0.00000 | 0.0537500 | 0.00000 | 0.12500 | 0.18750 | 0.0685680 |
| 112 | I | L | 0.06250 | 0.09375 | 0.1149688 | 0.09375 | 0.12500 | 0.21875 | 0.0407409 |
| 113 | I | M | 0.12500 | 0.12500 | 0.1468750 | 0.12500 | 0.18750 | 0.18750 | 0.0298255 |
| 114 | I | N | 0.00000 | 0.00000 | 0.0675625 | 0.06250 | 0.12500 | 0.25000 | 0.0742633 |
| 116 | I | P | 0.06250 | 0.06250 | 0.0734375 | 0.06250 | 0.09375 | 0.09375 | 0.0149128 |
| 117 | I | Q | 0.12500 | 0.12500 | 0.1468750 | 0.12500 | 0.18750 | 0.18750 | 0.0298255 |
| 119 | J | K | 0.00000 | 0.00000 | 0.0257500 | 0.00000 | 0.00000 | 0.12500 | 0.0505791 |
| 120 | J | L | 0.00000 | 0.00000 | 0.0640625 | 0.06250 | 0.12500 | 0.18750 | 0.0513509 |
| 121 | J | M | 0.00000 | 0.00000 | 0.0437500 | 0.00000 | 0.12500 | 0.12500 | 0.0596510 |
| 122 | J | N | 0.00000 | 0.00000 | 0.0541250 | 0.00000 | 0.12500 | 0.25000 | 0.0732989 |
| 124 | J | P | 0.00000 | 0.00000 | 0.0218750 | 0.00000 | 0.06250 | 0.06250 | 0.0298255 |
| 125 | J | Q | 0.00000 | 0.00000 | 0.0437500 | 0.00000 | 0.12500 | 0.12500 | 0.0596510 |
| 127 | K | L | 0.25000 | 0.25000 | 0.2704375 | 0.25000 | 0.31250 | 0.31250 | 0.0293345 |
| 128 | K | M | 0.00000 | 0.00000 | 0.0408750 | 0.00000 | 0.12500 | 0.12500 | 0.0586690 |
| 129 | K | N | 0.00000 | 0.00000 | 0.0266250 | 0.00000 | 0.00000 | 0.12500 | 0.0512041 |
| 131 | K | P | 0.00000 | 0.00000 | 0.0204375 | 0.00000 | 0.06250 | 0.06250 | 0.0293345 |
| 132 | K | Q | 0.00000 | 0.00000 | 0.0408750 | 0.00000 | 0.12500 | 0.12500 | 0.0586690 |
| 133 | L | L | 0.50000 | 0.50000 | 0.5204375 | 0.50000 | 0.56250 | 0.56250 | 0.0293345 |
| 134 | L | M | 0.06250 | 0.06250 | 0.0829375 | 0.06250 | 0.12500 | 0.12500 | 0.0293345 |
| 135 | L | N | 0.00000 | 0.00000 | 0.0640000 | 0.06250 | 0.12500 | 0.18750 | 0.0541329 |
| 137 | L | P | 0.03125 | 0.03125 | 0.0414688 | 0.03125 | 0.06250 | 0.06250 | 0.0146672 |
| 138 | L | Q | 0.06250 | 0.06250 | 0.0829375 | 0.06250 | 0.12500 | 0.12500 | 0.0293345 |
| 140 | M | N | 0.00000 | 0.00000 | 0.0405000 | 0.00000 | 0.12500 | 0.12500 | 0.0585293 |
| 146 | N | P | 0.00000 | 0.00000 | 0.0202500 | 0.00000 | 0.06250 | 0.06250 | 0.0292646 |
| 147 | N | Q | 0.00000 | 0.00000 | 0.0405000 | 0.00000 | 0.12500 | 0.12500 | 0.0585293 |
Comparing the values and variation found for the various kinship values:
stats_short <- stats_10[stats_10$sd > 0.0, ]
stats_long <- stats_1000[stats_1000$sd > 0.0, ]
## Align the short and long summaries by animal pair: the sd > 0 sets can
## differ in size between simulation lengths, so join on the ID pair rather
## than by row position.
merged <- merge(stats_short, stats_long, by = c("id_1", "id_2"),
suffixes = c("_short", "_long"))
comprison <- data.frame(
id_1 = merged$id_1,
id_2 = merged$id_2,
meanKin_short = merged$mean_short,
meanKin_long = merged$mean_long,
meanKinDelta = abs(merged$mean_short - merged$mean_long),
sdKin_short = merged$sd_short,
sdKin_long = merged$sd_long,
sdKinDelta = abs(merged$sd_short - merged$sd_long)
)
kable(comprison,
longtable = TRUE,
digits = c(0L, 0L, 4L, 4L, 4L, 4L, 4L, 4L),
caption = stri_c(
"Comparision of estimated kinships between simulations ",
"of 10 (short) and 1000 (long)"
)
) |>
kable_styling(
latex_options = c("striped", "repeat_header"),
repeat_header_method = "replace",
repeat_header_text = "\\textit{(continued)}",
font_size = 10L
)| id_1 | id_2 | meanKin_short | meanKin_long | meanKinDelta | sdKin_short | sdKin_long | sdKinDelta |
|---|---|---|---|---|---|---|---|
| A | E | 0.0750 | 0.0840 | 0.0090 | 0.1208 | 0.1181 | 0.0026 |
| A | F | 0.1625 | 0.1670 | 0.0045 | 0.0604 | 0.0591 | 0.0013 |
| A | G | 0.1625 | 0.1670 | 0.0045 | 0.0604 | 0.0591 | 0.0013 |
| A | I | 0.3125 | 0.2938 | 0.0187 | 0.0659 | 0.0597 | 0.0062 |
| A | J | 0.1250 | 0.0875 | 0.0375 | 0.1318 | 0.1193 | 0.0125 |
| A | N | 0.0500 | 0.0810 | 0.0310 | 0.1054 | 0.1171 | 0.0116 |
| B | E | 0.1500 | 0.1250 | 0.0250 | 0.1291 | 0.1251 | 0.0040 |
| B | F | 0.2000 | 0.1875 | 0.0125 | 0.0645 | 0.0625 | 0.0020 |
| B | G | 0.2000 | 0.1875 | 0.0125 | 0.0645 | 0.0625 | 0.0020 |
| B | I | 0.0750 | 0.0586 | 0.0164 | 0.0645 | 0.0624 | 0.0021 |
| B | J | 0.1500 | 0.1172 | 0.0328 | 0.1291 | 0.1248 | 0.0043 |
| B | N | 0.0500 | 0.1217 | 0.0717 | 0.1054 | 0.1250 | 0.0196 |
| C | E | 0.1125 | 0.1045 | 0.0080 | 0.0922 | 0.0853 | 0.0069 |
| C | F | 0.1812 | 0.1772 | 0.0040 | 0.0461 | 0.0426 | 0.0035 |
| C | G | 0.1812 | 0.1772 | 0.0040 | 0.0461 | 0.0426 | 0.0035 |
| C | I | 0.1938 | 0.1762 | 0.0176 | 0.0355 | 0.0421 | 0.0066 |
| C | J | 0.1375 | 0.1024 | 0.0351 | 0.0710 | 0.0841 | 0.0131 |
| C | N | 0.0500 | 0.1014 | 0.0514 | 0.0874 | 0.0878 | 0.0004 |
| D | E | 0.1125 | 0.1045 | 0.0080 | 0.0922 | 0.0853 | 0.0069 |
| D | F | 0.3062 | 0.3022 | 0.0040 | 0.0461 | 0.0426 | 0.0035 |
| D | G | 0.3062 | 0.3022 | 0.0040 | 0.0461 | 0.0426 | 0.0035 |
| D | I | 0.1938 | 0.1762 | 0.0176 | 0.0355 | 0.0421 | 0.0066 |
| D | J | 0.1375 | 0.1024 | 0.0351 | 0.0710 | 0.0841 | 0.0131 |
| D | N | 0.0500 | 0.1014 | 0.0514 | 0.0874 | 0.0878 | 0.0004 |
| E | F | 0.3062 | 0.3022 | 0.0040 | 0.0461 | 0.0426 | 0.0035 |
| E | G | 0.3062 | 0.3022 | 0.0040 | 0.0461 | 0.0426 | 0.0035 |
| E | H | 0.1125 | 0.1045 | 0.0080 | 0.0922 | 0.0853 | 0.0069 |
| E | I | 0.0875 | 0.0713 | 0.0162 | 0.0791 | 0.0741 | 0.0050 |
| E | J | 0.1000 | 0.0586 | 0.0414 | 0.0791 | 0.0747 | 0.0043 |
| E | K | 0.0625 | 0.0276 | 0.0349 | 0.0659 | 0.0519 | 0.0140 |
| E | L | 0.0875 | 0.0661 | 0.0214 | 0.0323 | 0.0533 | 0.0210 |
| E | M | 0.0375 | 0.0420 | 0.0045 | 0.0604 | 0.0591 | 0.0013 |
| E | N | 0.0375 | 0.0565 | 0.0190 | 0.0604 | 0.0722 | 0.0119 |
| E | P | 0.0187 | 0.0210 | 0.0023 | 0.0302 | 0.0295 | 0.0007 |
| E | Q | 0.0375 | 0.0420 | 0.0045 | 0.0604 | 0.0591 | 0.0013 |
| F | F | 0.5562 | 0.5522 | 0.0040 | 0.0461 | 0.0426 | 0.0035 |
| F | G | 0.3062 | 0.3022 | 0.0040 | 0.0461 | 0.0426 | 0.0035 |
| F | H | 0.1812 | 0.1772 | 0.0040 | 0.0461 | 0.0426 | 0.0035 |
| F | I | 0.1406 | 0.1238 | 0.0169 | 0.0423 | 0.0463 | 0.0040 |
| F | J | 0.1187 | 0.0805 | 0.0382 | 0.0547 | 0.0660 | 0.0112 |
| F | K | 0.0312 | 0.0343 | 0.0030 | 0.0329 | 0.0435 | 0.0105 |
| F | L | 0.1062 | 0.1057 | 0.0005 | 0.0161 | 0.0319 | 0.0158 |
| F | M | 0.0813 | 0.0835 | 0.0023 | 0.0302 | 0.0295 | 0.0007 |
| F | N | 0.0437 | 0.0789 | 0.0352 | 0.0593 | 0.0665 | 0.0072 |
| F | P | 0.0406 | 0.0418 | 0.0011 | 0.0151 | 0.0148 | 0.0003 |
| F | Q | 0.0813 | 0.0835 | 0.0023 | 0.0302 | 0.0295 | 0.0007 |
| G | G | 0.5562 | 0.5522 | 0.0040 | 0.0461 | 0.0426 | 0.0035 |
| G | H | 0.1812 | 0.1772 | 0.0040 | 0.0461 | 0.0426 | 0.0035 |
| G | I | 0.1406 | 0.1238 | 0.0169 | 0.0423 | 0.0463 | 0.0040 |
| G | J | 0.1187 | 0.0805 | 0.0382 | 0.0547 | 0.0660 | 0.0112 |
| G | K | 0.0312 | 0.0343 | 0.0030 | 0.0329 | 0.0435 | 0.0105 |
| G | L | 0.1062 | 0.1057 | 0.0005 | 0.0161 | 0.0319 | 0.0158 |
| G | M | 0.0813 | 0.0835 | 0.0023 | 0.0302 | 0.0295 | 0.0007 |
| G | N | 0.0437 | 0.0789 | 0.0352 | 0.0593 | 0.0665 | 0.0072 |
| G | P | 0.0406 | 0.0418 | 0.0011 | 0.0151 | 0.0148 | 0.0003 |
| G | Q | 0.0813 | 0.0835 | 0.0023 | 0.0302 | 0.0295 | 0.0007 |
| H | I | 0.1938 | 0.1762 | 0.0176 | 0.0355 | 0.0421 | 0.0066 |
| H | J | 0.1375 | 0.1024 | 0.0351 | 0.0710 | 0.0841 | 0.0131 |
| H | N | 0.0500 | 0.1014 | 0.0514 | 0.0874 | 0.0878 | 0.0004 |
| I | I | 0.5625 | 0.5438 | 0.0188 | 0.0659 | 0.0597 | 0.0062 |
| I | J | 0.3125 | 0.2938 | 0.0187 | 0.0659 | 0.0597 | 0.0062 |
| I | K | 0.0063 | 0.0538 | 0.0475 | 0.0198 | 0.0686 | 0.0488 |
| I | L | 0.1000 | 0.1150 | 0.0150 | 0.0198 | 0.0407 | 0.0210 |
| I | M | 0.1562 | 0.1469 | 0.0094 | 0.0329 | 0.0298 | 0.0031 |
| I | N | 0.0562 | 0.0676 | 0.0113 | 0.0952 | 0.0743 | 0.0210 |
| I | P | 0.0781 | 0.0734 | 0.0047 | 0.0165 | 0.0149 | 0.0016 |
| I | Q | 0.1562 | 0.1469 | 0.0094 | 0.0329 | 0.0298 | 0.0031 |
| J | K | 0.0125 | 0.0257 | 0.0132 | 0.0395 | 0.0506 | 0.0111 |
| J | L | 0.0750 | 0.0641 | 0.0109 | 0.0395 | 0.0514 | 0.0118 |
| J | M | 0.0625 | 0.0437 | 0.0188 | 0.0659 | 0.0597 | 0.0062 |
| J | N | 0.0625 | 0.0541 | 0.0084 | 0.1062 | 0.0733 | 0.0329 |
| J | P | 0.0312 | 0.0219 | 0.0094 | 0.0329 | 0.0298 | 0.0031 |
| J | Q | 0.0625 | 0.0437 | 0.0188 | 0.0659 | 0.0597 | 0.0062 |
| K | N | 0.0250 | 0.0266 | 0.0016 | 0.0527 | 0.0512 | 0.0015 |
| L | N | 0.0375 | 0.0640 | 0.0265 | 0.0527 | 0.0541 | 0.0014 |
| M | N | 0.0250 | 0.0405 | 0.0155 | 0.0527 | 0.0585 | 0.0058 |
| N | P | 0.0125 | 0.0203 | 0.0078 | 0.0264 | 0.0293 | 0.0029 |
| N | Q | 0.0250 | 0.0405 | 0.0155 | 0.0527 | 0.0585 | 0.0058 |
stats_short <- stats_100[stats_100$sd > 0.0, ]
stats_long <- stats_1000[stats_1000$sd > 0.0, ]
## Align the short and long summaries by animal pair: the sd > 0 sets can
## differ in size between simulation lengths, so join on the ID pair rather
## than by row position.
merged <- merge(stats_short, stats_long, by = c("id_1", "id_2"),
suffixes = c("_short", "_long"))
comprison <- data.frame(
id_1 = merged$id_1,
id_2 = merged$id_2,
meanKin_short = merged$mean_short,
meanKin_long = merged$mean_long,
meanKinDelta = abs(merged$mean_short - merged$mean_long),
sdKin_short = merged$sd_short,
sdKin_long = merged$sd_long,
sdKinDelta = abs(merged$sd_short - merged$sd_long)
)
kable(comprison,
longtable = TRUE,
digits = c(0L, 0L, 4L, 4L, 4L, 4L, 4L, 4L),
caption = stri_c(
"Comparision of estimated kinships between simulations ",
"of 100 (short) and 1000 (long)"
)
) |>
kable_styling(
latex_options = c("striped", "repeat_header"),
repeat_header_method = "replace",
repeat_header_text = "\\textit{(continued)}",
font_size = 10L
)| id_1 | id_2 | meanKin_short | meanKin_long | meanKinDelta | sdKin_short | sdKin_long | sdKinDelta |
|---|---|---|---|---|---|---|---|
| A | E | 0.0825 | 0.0840 | 0.0015 | 0.1181 | 0.1181 | 0.0000 |
| A | F | 0.1663 | 0.1670 | 0.0008 | 0.0591 | 0.0591 | 0.0000 |
| A | G | 0.1663 | 0.1670 | 0.0008 | 0.0591 | 0.0591 | 0.0000 |
| A | I | 0.2988 | 0.2938 | 0.0050 | 0.0613 | 0.0597 | 0.0016 |
| A | J | 0.0975 | 0.0875 | 0.0100 | 0.1226 | 0.1193 | 0.0032 |
| A | K | 0.0700 | 0.0818 | 0.0117 | 0.1128 | 0.1173 | 0.0045 |
| A | L | 0.1600 | 0.1659 | 0.0059 | 0.0564 | 0.0587 | 0.0023 |
| A | N | 0.0800 | 0.0810 | 0.0010 | 0.1172 | 0.1171 | 0.0001 |
| B | E | 0.1325 | 0.1250 | 0.0075 | 0.1254 | 0.1251 | 0.0003 |
| B | F | 0.1912 | 0.1875 | 0.0038 | 0.0627 | 0.0625 | 0.0002 |
| B | G | 0.1912 | 0.1875 | 0.0038 | 0.0627 | 0.0625 | 0.0002 |
| B | I | 0.0625 | 0.0586 | 0.0039 | 0.0628 | 0.0624 | 0.0004 |
| B | J | 0.1250 | 0.1172 | 0.0078 | 0.1256 | 0.1248 | 0.0008 |
| B | N | 0.1100 | 0.1217 | 0.0117 | 0.1247 | 0.1250 | 0.0003 |
| C | E | 0.1075 | 0.1045 | 0.0030 | 0.0871 | 0.0853 | 0.0018 |
| C | F | 0.1788 | 0.1772 | 0.0015 | 0.0435 | 0.0426 | 0.0009 |
| C | G | 0.1788 | 0.1772 | 0.0015 | 0.0435 | 0.0426 | 0.0009 |
| C | I | 0.1806 | 0.1762 | 0.0044 | 0.0386 | 0.0421 | 0.0034 |
| C | J | 0.1113 | 0.1024 | 0.0089 | 0.0772 | 0.0841 | 0.0069 |
| C | K | 0.0350 | 0.0409 | 0.0059 | 0.0564 | 0.0587 | 0.0023 |
| C | L | 0.2675 | 0.2704 | 0.0029 | 0.0282 | 0.0293 | 0.0011 |
| C | N | 0.0950 | 0.1014 | 0.0064 | 0.0925 | 0.0878 | 0.0047 |
| D | E | 0.1075 | 0.1045 | 0.0030 | 0.0871 | 0.0853 | 0.0018 |
| D | F | 0.3038 | 0.3022 | 0.0015 | 0.0435 | 0.0426 | 0.0009 |
| D | G | 0.3038 | 0.3022 | 0.0015 | 0.0435 | 0.0426 | 0.0009 |
| D | I | 0.1806 | 0.1762 | 0.0044 | 0.0386 | 0.0421 | 0.0034 |
| D | J | 0.1113 | 0.1024 | 0.0089 | 0.0772 | 0.0841 | 0.0069 |
| D | K | 0.0350 | 0.0409 | 0.0059 | 0.0564 | 0.0587 | 0.0023 |
| D | L | 0.1425 | 0.1454 | 0.0029 | 0.0282 | 0.0293 | 0.0011 |
| D | N | 0.0950 | 0.1014 | 0.0064 | 0.0925 | 0.0878 | 0.0047 |
| E | F | 0.3038 | 0.3022 | 0.0015 | 0.0435 | 0.0426 | 0.0009 |
| E | G | 0.3038 | 0.3022 | 0.0015 | 0.0435 | 0.0426 | 0.0009 |
| E | H | 0.1075 | 0.1045 | 0.0030 | 0.0871 | 0.0853 | 0.0018 |
| E | I | 0.0762 | 0.0713 | 0.0049 | 0.0730 | 0.0741 | 0.0010 |
| E | J | 0.0700 | 0.0586 | 0.0114 | 0.0801 | 0.0747 | 0.0054 |
| E | K | 0.0388 | 0.0276 | 0.0111 | 0.0581 | 0.0519 | 0.0062 |
| E | L | 0.0731 | 0.0661 | 0.0071 | 0.0533 | 0.0533 | 0.0001 |
| E | M | 0.0412 | 0.0420 | 0.0008 | 0.0591 | 0.0591 | 0.0000 |
| E | N | 0.0625 | 0.0565 | 0.0060 | 0.0743 | 0.0722 | 0.0021 |
| E | P | 0.0206 | 0.0210 | 0.0004 | 0.0295 | 0.0295 | 0.0000 |
| E | Q | 0.0412 | 0.0420 | 0.0008 | 0.0591 | 0.0591 | 0.0000 |
| F | F | 0.5538 | 0.5522 | 0.0015 | 0.0435 | 0.0426 | 0.0009 |
| F | G | 0.3038 | 0.3022 | 0.0015 | 0.0435 | 0.0426 | 0.0009 |
| F | H | 0.1788 | 0.1772 | 0.0015 | 0.0435 | 0.0426 | 0.0009 |
| F | I | 0.1284 | 0.1238 | 0.0047 | 0.0426 | 0.0463 | 0.0037 |
| F | J | 0.0906 | 0.0805 | 0.0101 | 0.0637 | 0.0660 | 0.0023 |
| F | K | 0.0369 | 0.0343 | 0.0026 | 0.0436 | 0.0435 | 0.0001 |
| F | L | 0.1078 | 0.1057 | 0.0021 | 0.0321 | 0.0319 | 0.0002 |
| F | M | 0.0831 | 0.0835 | 0.0004 | 0.0295 | 0.0295 | 0.0000 |
| F | N | 0.0788 | 0.0789 | 0.0002 | 0.0720 | 0.0665 | 0.0055 |
| F | P | 0.0416 | 0.0418 | 0.0002 | 0.0148 | 0.0148 | 0.0000 |
| F | Q | 0.0831 | 0.0835 | 0.0004 | 0.0295 | 0.0295 | 0.0000 |
| G | G | 0.5538 | 0.5522 | 0.0015 | 0.0435 | 0.0426 | 0.0009 |
| G | H | 0.1788 | 0.1772 | 0.0015 | 0.0435 | 0.0426 | 0.0009 |
| G | I | 0.1284 | 0.1238 | 0.0047 | 0.0426 | 0.0463 | 0.0037 |
| G | J | 0.0906 | 0.0805 | 0.0101 | 0.0637 | 0.0660 | 0.0023 |
| G | K | 0.0369 | 0.0343 | 0.0026 | 0.0436 | 0.0435 | 0.0001 |
| G | L | 0.1078 | 0.1057 | 0.0021 | 0.0321 | 0.0319 | 0.0002 |
| G | M | 0.0831 | 0.0835 | 0.0004 | 0.0295 | 0.0295 | 0.0000 |
| G | N | 0.0788 | 0.0789 | 0.0002 | 0.0720 | 0.0665 | 0.0055 |
| G | P | 0.0416 | 0.0418 | 0.0002 | 0.0148 | 0.0148 | 0.0000 |
| G | Q | 0.0831 | 0.0835 | 0.0004 | 0.0295 | 0.0295 | 0.0000 |
| H | I | 0.1806 | 0.1762 | 0.0044 | 0.0386 | 0.0421 | 0.0034 |
| H | J | 0.1113 | 0.1024 | 0.0089 | 0.0772 | 0.0841 | 0.0069 |
| H | K | 0.0350 | 0.0409 | 0.0059 | 0.0564 | 0.0587 | 0.0023 |
| H | L | 0.1425 | 0.1454 | 0.0029 | 0.0282 | 0.0293 | 0.0011 |
| H | N | 0.0950 | 0.1014 | 0.0064 | 0.0925 | 0.0878 | 0.0047 |
| I | I | 0.5488 | 0.5438 | 0.0050 | 0.0613 | 0.0597 | 0.0016 |
| I | J | 0.2988 | 0.2938 | 0.0050 | 0.0613 | 0.0597 | 0.0016 |
| I | K | 0.0469 | 0.0538 | 0.0069 | 0.0649 | 0.0686 | 0.0037 |
| I | L | 0.1138 | 0.1150 | 0.0012 | 0.0360 | 0.0407 | 0.0048 |
| I | M | 0.1494 | 0.1469 | 0.0025 | 0.0306 | 0.0298 | 0.0008 |
| I | N | 0.0638 | 0.0676 | 0.0038 | 0.0794 | 0.0743 | 0.0052 |
| I | P | 0.0747 | 0.0734 | 0.0013 | 0.0153 | 0.0149 | 0.0004 |
| I | Q | 0.1494 | 0.1469 | 0.0025 | 0.0306 | 0.0298 | 0.0008 |
| J | K | 0.0238 | 0.0257 | 0.0020 | 0.0493 | 0.0506 | 0.0013 |
| J | L | 0.0675 | 0.0641 | 0.0034 | 0.0467 | 0.0514 | 0.0046 |
| J | M | 0.0488 | 0.0437 | 0.0050 | 0.0613 | 0.0597 | 0.0016 |
| J | N | 0.0475 | 0.0541 | 0.0066 | 0.0728 | 0.0733 | 0.0005 |
| J | P | 0.0244 | 0.0219 | 0.0025 | 0.0306 | 0.0298 | 0.0008 |
| J | Q | 0.0488 | 0.0437 | 0.0050 | 0.0613 | 0.0597 | 0.0016 |
| K | L | 0.2675 | 0.2704 | 0.0029 | 0.0282 | 0.0293 | 0.0011 |
| K | M | 0.0350 | 0.0409 | 0.0059 | 0.0564 | 0.0587 | 0.0023 |
| K | N | 0.0288 | 0.0266 | 0.0021 | 0.0529 | 0.0512 | 0.0017 |
| K | P | 0.0175 | 0.0204 | 0.0029 | 0.0282 | 0.0293 | 0.0011 |
| K | Q | 0.0350 | 0.0409 | 0.0059 | 0.0564 | 0.0587 | 0.0023 |
| L | L | 0.5175 | 0.5204 | 0.0029 | 0.0282 | 0.0293 | 0.0011 |
| L | M | 0.0800 | 0.0829 | 0.0029 | 0.0282 | 0.0293 | 0.0011 |
| L | N | 0.0619 | 0.0640 | 0.0021 | 0.0537 | 0.0541 | 0.0005 |
| L | P | 0.0400 | 0.0415 | 0.0015 | 0.0141 | 0.0147 | 0.0006 |
| L | Q | 0.0800 | 0.0829 | 0.0029 | 0.0282 | 0.0293 | 0.0011 |
| M | N | 0.0400 | 0.0405 | 0.0005 | 0.0586 | 0.0585 | 0.0001 |
| N | P | 0.0200 | 0.0203 | 0.0003 | 0.0293 | 0.0293 | 0.0000 |
| N | Q | 0.0400 | 0.0405 | 0.0005 | 0.0586 | 0.0585 | 0.0001 |