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.
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.
This tutorial assumes knowledge of potential parents and does not present methods for identifying potential parents.
Capabilities to be address with resolution of Issue #281 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.
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)
library(magrittr)
library(nprcgenekeepr)
library(stringi)
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)]
}
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" "sim_9"
## [10] "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] 94
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.050000 | 0.00000 | 0.00000 | 0.25000 | 0.1054093 |
6 | A | F | 0.12500 | 0.12500 | 0.150000 | 0.12500 | 0.12500 | 0.25000 | 0.0527046 |
7 | A | G | 0.12500 | 0.12500 | 0.150000 | 0.12500 | 0.12500 | 0.25000 | 0.0527046 |
9 | A | I | 0.25000 | 0.25000 | 0.300000 | 0.25000 | 0.37500 | 0.37500 | 0.0645497 |
10 | A | J | 0.00000 | 0.00000 | 0.100000 | 0.00000 | 0.25000 | 0.25000 | 0.1290994 |
11 | A | K | 0.00000 | 0.00000 | 0.050000 | 0.00000 | 0.00000 | 0.25000 | 0.1054093 |
12 | A | L | 0.12500 | 0.12500 | 0.150000 | 0.12500 | 0.12500 | 0.25000 | 0.0527046 |
14 | A | N | 0.00000 | 0.00000 | 0.075000 | 0.00000 | 0.25000 | 0.25000 | 0.1207615 |
21 | B | E | 0.00000 | 0.00000 | 0.075000 | 0.00000 | 0.25000 | 0.25000 | 0.1207615 |
22 | B | F | 0.12500 | 0.12500 | 0.162500 | 0.12500 | 0.25000 | 0.25000 | 0.0603807 |
23 | B | G | 0.12500 | 0.12500 | 0.162500 | 0.12500 | 0.25000 | 0.25000 | 0.0603807 |
25 | B | I | 0.00000 | 0.00000 | 0.087500 | 0.12500 | 0.12500 | 0.12500 | 0.0603807 |
26 | B | J | 0.00000 | 0.00000 | 0.175000 | 0.25000 | 0.25000 | 0.25000 | 0.1207615 |
30 | B | N | 0.00000 | 0.00000 | 0.100000 | 0.00000 | 0.25000 | 0.25000 | 0.1290994 |
36 | C | E | 0.00000 | 0.00000 | 0.062500 | 0.00000 | 0.12500 | 0.25000 | 0.0883883 |
37 | C | F | 0.12500 | 0.12500 | 0.156250 | 0.12500 | 0.18750 | 0.25000 | 0.0441942 |
38 | C | G | 0.12500 | 0.12500 | 0.156250 | 0.12500 | 0.18750 | 0.25000 | 0.0441942 |
40 | C | I | 0.18750 | 0.18750 | 0.193750 | 0.18750 | 0.18750 | 0.25000 | 0.0197642 |
41 | C | J | 0.12500 | 0.12500 | 0.137500 | 0.12500 | 0.12500 | 0.25000 | 0.0395285 |
42 | C | K | 0.00000 | 0.00000 | 0.025000 | 0.00000 | 0.00000 | 0.12500 | 0.0527046 |
43 | C | L | 0.25000 | 0.25000 | 0.262500 | 0.25000 | 0.25000 | 0.31250 | 0.0263523 |
45 | C | N | 0.00000 | 0.00000 | 0.087500 | 0.12500 | 0.12500 | 0.12500 | 0.0603807 |
50 | D | E | 0.00000 | 0.00000 | 0.062500 | 0.00000 | 0.12500 | 0.25000 | 0.0883883 |
51 | D | F | 0.25000 | 0.25000 | 0.281250 | 0.25000 | 0.31250 | 0.37500 | 0.0441942 |
52 | D | G | 0.25000 | 0.25000 | 0.281250 | 0.25000 | 0.31250 | 0.37500 | 0.0441942 |
54 | D | I | 0.18750 | 0.18750 | 0.193750 | 0.18750 | 0.18750 | 0.25000 | 0.0197642 |
55 | D | J | 0.12500 | 0.12500 | 0.137500 | 0.12500 | 0.12500 | 0.25000 | 0.0395285 |
56 | D | K | 0.00000 | 0.00000 | 0.025000 | 0.00000 | 0.00000 | 0.12500 | 0.0527046 |
57 | D | L | 0.12500 | 0.12500 | 0.137500 | 0.12500 | 0.12500 | 0.18750 | 0.0263523 |
59 | D | N | 0.00000 | 0.00000 | 0.087500 | 0.12500 | 0.12500 | 0.12500 | 0.0603807 |
64 | E | F | 0.25000 | 0.25000 | 0.281250 | 0.25000 | 0.31250 | 0.37500 | 0.0441942 |
65 | E | G | 0.25000 | 0.25000 | 0.281250 | 0.25000 | 0.31250 | 0.37500 | 0.0441942 |
66 | E | H | 0.00000 | 0.00000 | 0.062500 | 0.00000 | 0.12500 | 0.25000 | 0.0883883 |
67 | E | I | 0.00000 | 0.00000 | 0.056250 | 0.03125 | 0.06250 | 0.18750 | 0.0748262 |
68 | E | J | 0.00000 | 0.00000 | 0.062500 | 0.06250 | 0.12500 | 0.12500 | 0.0658808 |
69 | E | K | 0.00000 | 0.00000 | 0.012500 | 0.00000 | 0.00000 | 0.12500 | 0.0395285 |
70 | E | L | 0.00000 | 0.00000 | 0.037500 | 0.03125 | 0.06250 | 0.12500 | 0.0437004 |
71 | E | M | 0.00000 | 0.00000 | 0.025000 | 0.00000 | 0.00000 | 0.12500 | 0.0527046 |
72 | E | N | 0.00000 | 0.00000 | 0.050000 | 0.00000 | 0.12500 | 0.12500 | 0.0645497 |
74 | E | P | 0.00000 | 0.00000 | 0.012500 | 0.00000 | 0.00000 | 0.06250 | 0.0263523 |
75 | E | Q | 0.00000 | 0.00000 | 0.025000 | 0.00000 | 0.00000 | 0.12500 | 0.0527046 |
76 | F | F | 0.50000 | 0.50000 | 0.531250 | 0.50000 | 0.56250 | 0.62500 | 0.0441942 |
77 | F | G | 0.25000 | 0.25000 | 0.281250 | 0.25000 | 0.31250 | 0.37500 | 0.0441942 |
78 | F | H | 0.12500 | 0.12500 | 0.156250 | 0.12500 | 0.18750 | 0.25000 | 0.0441942 |
79 | F | I | 0.09375 | 0.09375 | 0.125000 | 0.12500 | 0.12500 | 0.18750 | 0.0360844 |
80 | F | J | 0.06250 | 0.06250 | 0.100000 | 0.12500 | 0.12500 | 0.12500 | 0.0322749 |
81 | F | K | 0.00000 | 0.00000 | 0.018750 | 0.00000 | 0.06250 | 0.06250 | 0.0301904 |
82 | F | L | 0.06250 | 0.06250 | 0.087500 | 0.09375 | 0.09375 | 0.12500 | 0.0197642 |
83 | F | M | 0.06250 | 0.06250 | 0.075000 | 0.06250 | 0.06250 | 0.12500 | 0.0263523 |
84 | F | N | 0.00000 | 0.00000 | 0.068750 | 0.06250 | 0.12500 | 0.12500 | 0.0461165 |
86 | F | P | 0.03125 | 0.03125 | 0.037500 | 0.03125 | 0.03125 | 0.06250 | 0.0131762 |
87 | F | Q | 0.06250 | 0.06250 | 0.075000 | 0.06250 | 0.06250 | 0.12500 | 0.0263523 |
88 | G | G | 0.50000 | 0.50000 | 0.531250 | 0.50000 | 0.56250 | 0.62500 | 0.0441942 |
89 | G | H | 0.12500 | 0.12500 | 0.156250 | 0.12500 | 0.18750 | 0.25000 | 0.0441942 |
90 | G | I | 0.09375 | 0.09375 | 0.125000 | 0.12500 | 0.12500 | 0.18750 | 0.0360844 |
91 | G | J | 0.06250 | 0.06250 | 0.100000 | 0.12500 | 0.12500 | 0.12500 | 0.0322749 |
92 | G | K | 0.00000 | 0.00000 | 0.018750 | 0.00000 | 0.06250 | 0.06250 | 0.0301904 |
93 | G | L | 0.06250 | 0.06250 | 0.087500 | 0.09375 | 0.09375 | 0.12500 | 0.0197642 |
94 | G | M | 0.06250 | 0.06250 | 0.075000 | 0.06250 | 0.06250 | 0.12500 | 0.0263523 |
95 | G | N | 0.00000 | 0.00000 | 0.068750 | 0.06250 | 0.12500 | 0.12500 | 0.0461165 |
97 | G | P | 0.03125 | 0.03125 | 0.037500 | 0.03125 | 0.03125 | 0.06250 | 0.0131762 |
98 | G | Q | 0.06250 | 0.06250 | 0.075000 | 0.06250 | 0.06250 | 0.12500 | 0.0263523 |
100 | H | I | 0.18750 | 0.18750 | 0.193750 | 0.18750 | 0.18750 | 0.25000 | 0.0197642 |
101 | H | J | 0.12500 | 0.12500 | 0.137500 | 0.12500 | 0.12500 | 0.25000 | 0.0395285 |
102 | H | K | 0.00000 | 0.00000 | 0.025000 | 0.00000 | 0.00000 | 0.12500 | 0.0527046 |
103 | H | L | 0.12500 | 0.12500 | 0.137500 | 0.12500 | 0.12500 | 0.18750 | 0.0263523 |
105 | H | N | 0.00000 | 0.00000 | 0.087500 | 0.12500 | 0.12500 | 0.12500 | 0.0603807 |
109 | I | I | 0.50000 | 0.50000 | 0.550000 | 0.50000 | 0.62500 | 0.62500 | 0.0645497 |
110 | I | J | 0.25000 | 0.25000 | 0.300000 | 0.25000 | 0.37500 | 0.37500 | 0.0645497 |
111 | I | K | 0.00000 | 0.00000 | 0.037500 | 0.00000 | 0.06250 | 0.18750 | 0.0671855 |
112 | I | L | 0.09375 | 0.09375 | 0.115625 | 0.09375 | 0.12500 | 0.18750 | 0.0331047 |
113 | I | M | 0.12500 | 0.12500 | 0.150000 | 0.12500 | 0.18750 | 0.18750 | 0.0322749 |
114 | I | N | 0.00000 | 0.00000 | 0.068750 | 0.06250 | 0.12500 | 0.18750 | 0.0687816 |
116 | I | P | 0.06250 | 0.06250 | 0.075000 | 0.06250 | 0.09375 | 0.09375 | 0.0161374 |
117 | I | Q | 0.12500 | 0.12500 | 0.150000 | 0.12500 | 0.18750 | 0.18750 | 0.0322749 |
119 | J | K | 0.00000 | 0.00000 | 0.025000 | 0.00000 | 0.00000 | 0.12500 | 0.0527046 |
120 | J | L | 0.06250 | 0.06250 | 0.081250 | 0.06250 | 0.12500 | 0.12500 | 0.0301904 |
121 | J | M | 0.00000 | 0.00000 | 0.050000 | 0.00000 | 0.12500 | 0.12500 | 0.0645497 |
122 | J | N | 0.00000 | 0.00000 | 0.062500 | 0.00000 | 0.12500 | 0.25000 | 0.0883883 |
124 | J | P | 0.00000 | 0.00000 | 0.025000 | 0.00000 | 0.06250 | 0.06250 | 0.0322749 |
125 | J | Q | 0.00000 | 0.00000 | 0.050000 | 0.00000 | 0.12500 | 0.12500 | 0.0645497 |
127 | K | L | 0.25000 | 0.25000 | 0.262500 | 0.25000 | 0.25000 | 0.31250 | 0.0263523 |
128 | K | M | 0.00000 | 0.00000 | 0.025000 | 0.00000 | 0.00000 | 0.12500 | 0.0527046 |
129 | K | N | 0.00000 | 0.00000 | 0.012500 | 0.00000 | 0.00000 | 0.12500 | 0.0395285 |
131 | K | P | 0.00000 | 0.00000 | 0.012500 | 0.00000 | 0.00000 | 0.06250 | 0.0263523 |
132 | K | Q | 0.00000 | 0.00000 | 0.025000 | 0.00000 | 0.00000 | 0.12500 | 0.0527046 |
133 | L | L | 0.50000 | 0.50000 | 0.512500 | 0.50000 | 0.50000 | 0.56250 | 0.0263523 |
134 | L | M | 0.06250 | 0.06250 | 0.075000 | 0.06250 | 0.06250 | 0.12500 | 0.0263523 |
135 | L | N | 0.00000 | 0.00000 | 0.050000 | 0.06250 | 0.06250 | 0.06250 | 0.0263523 |
137 | L | P | 0.03125 | 0.03125 | 0.037500 | 0.03125 | 0.03125 | 0.06250 | 0.0131762 |
138 | L | Q | 0.06250 | 0.06250 | 0.075000 | 0.06250 | 0.06250 | 0.12500 | 0.0263523 |
140 | M | N | 0.00000 | 0.00000 | 0.037500 | 0.00000 | 0.12500 | 0.12500 | 0.0603807 |
146 | N | P | 0.00000 | 0.00000 | 0.018750 | 0.00000 | 0.06250 | 0.06250 | 0.0301904 |
147 | N | Q | 0.00000 | 0.00000 | 0.037500 | 0.00000 | 0.12500 | 0.12500 | 0.0603807 |
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" "sim_9"
## [10] "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.1000000 | 0.00000 | 0.25000 | 0.25000 | 0.1230915 |
6 | A | F | 0.12500 | 0.12500 | 0.1750000 | 0.12500 | 0.25000 | 0.25000 | 0.0615457 |
7 | A | G | 0.12500 | 0.12500 | 0.1750000 | 0.12500 | 0.25000 | 0.25000 | 0.0615457 |
9 | A | I | 0.25000 | 0.25000 | 0.2875000 | 0.25000 | 0.37500 | 0.37500 | 0.0575708 |
10 | A | J | 0.00000 | 0.00000 | 0.0750000 | 0.00000 | 0.25000 | 0.25000 | 0.1151415 |
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.0725000 | 0.00000 | 0.25000 | 0.25000 | 0.1140120 |
21 | B | E | 0.00000 | 0.00000 | 0.1350000 | 0.25000 | 0.25000 | 0.25000 | 0.1252271 |
22 | B | F | 0.12500 | 0.12500 | 0.1925000 | 0.25000 | 0.25000 | 0.25000 | 0.0626135 |
23 | B | G | 0.12500 | 0.12500 | 0.1925000 | 0.25000 | 0.25000 | 0.25000 | 0.0626135 |
25 | B | I | 0.00000 | 0.00000 | 0.0587500 | 0.00000 | 0.12500 | 0.12500 | 0.0627017 |
26 | B | J | 0.00000 | 0.00000 | 0.1175000 | 0.00000 | 0.25000 | 0.25000 | 0.1254034 |
30 | B | N | 0.00000 | 0.00000 | 0.1225000 | 0.00000 | 0.25000 | 0.25000 | 0.1256046 |
36 | C | E | 0.00000 | 0.00000 | 0.1175000 | 0.12500 | 0.25000 | 0.25000 | 0.0970200 |
37 | C | F | 0.12500 | 0.12500 | 0.1837500 | 0.18750 | 0.25000 | 0.25000 | 0.0485100 |
38 | C | G | 0.12500 | 0.12500 | 0.1837500 | 0.18750 | 0.25000 | 0.25000 | 0.0485100 |
40 | C | I | 0.12500 | 0.12500 | 0.1731250 | 0.18750 | 0.18750 | 0.25000 | 0.0395833 |
41 | C | J | 0.00000 | 0.00000 | 0.0962500 | 0.12500 | 0.12500 | 0.25000 | 0.0791667 |
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.0975000 | 0.12500 | 0.12500 | 0.25000 | 0.0786165 |
50 | D | E | 0.00000 | 0.00000 | 0.1175000 | 0.12500 | 0.25000 | 0.25000 | 0.0970200 |
51 | D | F | 0.25000 | 0.25000 | 0.3087500 | 0.31250 | 0.37500 | 0.37500 | 0.0485100 |
52 | D | G | 0.25000 | 0.25000 | 0.3087500 | 0.31250 | 0.37500 | 0.37500 | 0.0485100 |
54 | D | I | 0.12500 | 0.12500 | 0.1731250 | 0.18750 | 0.18750 | 0.25000 | 0.0395833 |
55 | D | J | 0.00000 | 0.00000 | 0.0962500 | 0.12500 | 0.12500 | 0.25000 | 0.0791667 |
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.0975000 | 0.12500 | 0.12500 | 0.25000 | 0.0786165 |
64 | E | F | 0.25000 | 0.25000 | 0.3087500 | 0.31250 | 0.37500 | 0.37500 | 0.0485100 |
65 | E | G | 0.25000 | 0.25000 | 0.3087500 | 0.31250 | 0.37500 | 0.37500 | 0.0485100 |
66 | E | H | 0.00000 | 0.00000 | 0.1175000 | 0.12500 | 0.25000 | 0.25000 | 0.0970200 |
67 | E | I | 0.00000 | 0.00000 | 0.0812500 | 0.06250 | 0.12500 | 0.25000 | 0.0792065 |
68 | E | J | 0.00000 | 0.00000 | 0.0625000 | 0.00000 | 0.12500 | 0.25000 | 0.0743235 |
69 | E | K | 0.00000 | 0.00000 | 0.0275000 | 0.00000 | 0.00000 | 0.12500 | 0.0520416 |
70 | E | L | 0.00000 | 0.00000 | 0.0725000 | 0.06250 | 0.12500 | 0.18750 | 0.0587378 |
71 | E | M | 0.00000 | 0.00000 | 0.0500000 | 0.00000 | 0.12500 | 0.12500 | 0.0615457 |
72 | E | N | 0.00000 | 0.00000 | 0.0625000 | 0.00000 | 0.12500 | 0.25000 | 0.0764176 |
74 | E | P | 0.00000 | 0.00000 | 0.0250000 | 0.00000 | 0.06250 | 0.06250 | 0.0307729 |
75 | E | Q | 0.00000 | 0.00000 | 0.0500000 | 0.00000 | 0.12500 | 0.12500 | 0.0615457 |
76 | F | F | 0.50000 | 0.50000 | 0.5587500 | 0.56250 | 0.62500 | 0.62500 | 0.0485100 |
77 | F | G | 0.25000 | 0.25000 | 0.3087500 | 0.31250 | 0.37500 | 0.37500 | 0.0485100 |
78 | F | H | 0.12500 | 0.12500 | 0.1837500 | 0.18750 | 0.25000 | 0.25000 | 0.0485100 |
79 | F | I | 0.06250 | 0.06250 | 0.1271875 | 0.12500 | 0.15625 | 0.25000 | 0.0478909 |
80 | F | J | 0.00000 | 0.00000 | 0.0793750 | 0.06250 | 0.12500 | 0.25000 | 0.0639695 |
81 | F | K | 0.00000 | 0.00000 | 0.0312500 | 0.00000 | 0.06250 | 0.12500 | 0.0439704 |
82 | F | L | 0.06250 | 0.06250 | 0.1075000 | 0.09375 | 0.12500 | 0.18750 | 0.0344967 |
83 | F | M | 0.06250 | 0.06250 | 0.0875000 | 0.06250 | 0.12500 | 0.12500 | 0.0307729 |
84 | F | N | 0.00000 | 0.00000 | 0.0800000 | 0.06250 | 0.12500 | 0.25000 | 0.0634896 |
86 | F | P | 0.03125 | 0.03125 | 0.0437500 | 0.03125 | 0.06250 | 0.06250 | 0.0153864 |
87 | F | Q | 0.06250 | 0.06250 | 0.0875000 | 0.06250 | 0.12500 | 0.12500 | 0.0307729 |
88 | G | G | 0.50000 | 0.50000 | 0.5587500 | 0.56250 | 0.62500 | 0.62500 | 0.0485100 |
89 | G | H | 0.12500 | 0.12500 | 0.1837500 | 0.18750 | 0.25000 | 0.25000 | 0.0485100 |
90 | G | I | 0.06250 | 0.06250 | 0.1271875 | 0.12500 | 0.15625 | 0.25000 | 0.0478909 |
91 | G | J | 0.00000 | 0.00000 | 0.0793750 | 0.06250 | 0.12500 | 0.25000 | 0.0639695 |
92 | G | K | 0.00000 | 0.00000 | 0.0312500 | 0.00000 | 0.06250 | 0.12500 | 0.0439704 |
93 | G | L | 0.06250 | 0.06250 | 0.1075000 | 0.09375 | 0.12500 | 0.18750 | 0.0344967 |
94 | G | M | 0.06250 | 0.06250 | 0.0875000 | 0.06250 | 0.12500 | 0.12500 | 0.0307729 |
95 | G | N | 0.00000 | 0.00000 | 0.0800000 | 0.06250 | 0.12500 | 0.25000 | 0.0634896 |
97 | G | P | 0.03125 | 0.03125 | 0.0437500 | 0.03125 | 0.06250 | 0.06250 | 0.0153864 |
98 | G | Q | 0.06250 | 0.06250 | 0.0875000 | 0.06250 | 0.12500 | 0.12500 | 0.0307729 |
100 | H | I | 0.12500 | 0.12500 | 0.1731250 | 0.18750 | 0.18750 | 0.25000 | 0.0395833 |
101 | H | J | 0.00000 | 0.00000 | 0.0962500 | 0.12500 | 0.12500 | 0.25000 | 0.0791667 |
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.0975000 | 0.12500 | 0.12500 | 0.25000 | 0.0786165 |
109 | I | I | 0.50000 | 0.50000 | 0.5375000 | 0.50000 | 0.62500 | 0.62500 | 0.0575708 |
110 | I | J | 0.25000 | 0.25000 | 0.2875000 | 0.25000 | 0.37500 | 0.37500 | 0.0575708 |
111 | I | K | 0.00000 | 0.00000 | 0.0481250 | 0.00000 | 0.12500 | 0.18750 | 0.0657939 |
112 | I | L | 0.06250 | 0.06250 | 0.1106250 | 0.09375 | 0.12500 | 0.21875 | 0.0383171 |
113 | I | M | 0.12500 | 0.12500 | 0.1437500 | 0.12500 | 0.18750 | 0.18750 | 0.0287854 |
114 | I | N | 0.00000 | 0.00000 | 0.0662500 | 0.06250 | 0.12500 | 0.18750 | 0.0651702 |
116 | I | P | 0.06250 | 0.06250 | 0.0718750 | 0.06250 | 0.09375 | 0.09375 | 0.0143927 |
117 | I | Q | 0.12500 | 0.12500 | 0.1437500 | 0.12500 | 0.18750 | 0.18750 | 0.0287854 |
119 | J | K | 0.00000 | 0.00000 | 0.0262500 | 0.00000 | 0.00000 | 0.12500 | 0.0511700 |
120 | J | L | 0.00000 | 0.00000 | 0.0612500 | 0.06250 | 0.06250 | 0.18750 | 0.0478219 |
121 | J | M | 0.00000 | 0.00000 | 0.0375000 | 0.00000 | 0.12500 | 0.12500 | 0.0575708 |
122 | J | N | 0.00000 | 0.00000 | 0.0600000 | 0.00000 | 0.12500 | 0.25000 | 0.0721250 |
124 | J | P | 0.00000 | 0.00000 | 0.0187500 | 0.00000 | 0.06250 | 0.06250 | 0.0287854 |
125 | J | Q | 0.00000 | 0.00000 | 0.0375000 | 0.00000 | 0.12500 | 0.12500 | 0.0575708 |
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.0200000 | 0.00000 | 0.00000 | 0.12500 | 0.0460566 |
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.0587500 | 0.06250 | 0.06250 | 0.18750 | 0.0460052 |
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.0362500 | 0.00000 | 0.12500 | 0.12500 | 0.0570060 |
146 | N | P | 0.00000 | 0.00000 | 0.0181250 | 0.00000 | 0.06250 | 0.06250 | 0.0285030 |
147 | N | Q | 0.00000 | 0.00000 | 0.0362500 | 0.00000 | 0.12500 | 0.12500 | 0.0570060 |
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" "sim_9"
## [10] "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.0855000 | 0.00000 | 0.25000 | 0.25000 | 0.1186542 |
6 | A | F | 0.12500 | 0.12500 | 0.1677500 | 0.12500 | 0.25000 | 0.25000 | 0.0593271 |
7 | A | G | 0.12500 | 0.12500 | 0.1677500 | 0.12500 | 0.25000 | 0.25000 | 0.0593271 |
9 | A | I | 0.25000 | 0.25000 | 0.2902500 | 0.25000 | 0.37500 | 0.37500 | 0.0584346 |
10 | A | J | 0.00000 | 0.00000 | 0.0805000 | 0.00000 | 0.25000 | 0.25000 | 0.1168692 |
11 | A | K | 0.00000 | 0.00000 | 0.0860000 | 0.00000 | 0.25000 | 0.25000 | 0.1188197 |
12 | A | L | 0.12500 | 0.12500 | 0.1680000 | 0.12500 | 0.25000 | 0.25000 | 0.0594098 |
14 | A | N | 0.00000 | 0.00000 | 0.0842500 | 0.00000 | 0.25000 | 0.25000 | 0.1182304 |
21 | B | E | 0.00000 | 0.00000 | 0.1297500 | 0.25000 | 0.25000 | 0.25000 | 0.1249722 |
22 | B | F | 0.12500 | 0.12500 | 0.1898750 | 0.25000 | 0.25000 | 0.25000 | 0.0624861 |
23 | B | G | 0.12500 | 0.12500 | 0.1898750 | 0.25000 | 0.25000 | 0.25000 | 0.0624861 |
25 | B | I | 0.00000 | 0.00000 | 0.0623750 | 0.00000 | 0.12500 | 0.12500 | 0.0625311 |
26 | B | J | 0.00000 | 0.00000 | 0.1247500 | 0.00000 | 0.25000 | 0.25000 | 0.1250623 |
30 | B | N | 0.00000 | 0.00000 | 0.1247500 | 0.00000 | 0.25000 | 0.25000 | 0.1250623 |
36 | C | E | 0.00000 | 0.00000 | 0.1076250 | 0.12500 | 0.12500 | 0.25000 | 0.0873362 |
37 | C | F | 0.12500 | 0.12500 | 0.1788125 | 0.18750 | 0.18750 | 0.25000 | 0.0436681 |
38 | C | G | 0.12500 | 0.12500 | 0.1788125 | 0.18750 | 0.18750 | 0.25000 | 0.0436681 |
40 | C | I | 0.12500 | 0.12500 | 0.1763125 | 0.18750 | 0.18750 | 0.25000 | 0.0426388 |
41 | C | J | 0.00000 | 0.00000 | 0.1026250 | 0.12500 | 0.12500 | 0.25000 | 0.0852775 |
42 | C | K | 0.00000 | 0.00000 | 0.0430000 | 0.00000 | 0.12500 | 0.12500 | 0.0594098 |
43 | C | L | 0.25000 | 0.25000 | 0.2715000 | 0.25000 | 0.31250 | 0.31250 | 0.0297049 |
45 | C | N | 0.00000 | 0.00000 | 0.1045000 | 0.12500 | 0.12500 | 0.25000 | 0.0867455 |
50 | D | E | 0.00000 | 0.00000 | 0.1076250 | 0.12500 | 0.12500 | 0.25000 | 0.0873362 |
51 | D | F | 0.25000 | 0.25000 | 0.3038125 | 0.31250 | 0.31250 | 0.37500 | 0.0436681 |
52 | D | G | 0.25000 | 0.25000 | 0.3038125 | 0.31250 | 0.31250 | 0.37500 | 0.0436681 |
54 | D | I | 0.12500 | 0.12500 | 0.1763125 | 0.18750 | 0.18750 | 0.25000 | 0.0426388 |
55 | D | J | 0.00000 | 0.00000 | 0.1026250 | 0.12500 | 0.12500 | 0.25000 | 0.0852775 |
56 | D | K | 0.00000 | 0.00000 | 0.0430000 | 0.00000 | 0.12500 | 0.12500 | 0.0594098 |
57 | D | L | 0.12500 | 0.12500 | 0.1465000 | 0.12500 | 0.18750 | 0.18750 | 0.0297049 |
59 | D | N | 0.00000 | 0.00000 | 0.1045000 | 0.12500 | 0.12500 | 0.25000 | 0.0867455 |
64 | E | F | 0.25000 | 0.25000 | 0.3038125 | 0.31250 | 0.31250 | 0.37500 | 0.0436681 |
65 | E | G | 0.25000 | 0.25000 | 0.3038125 | 0.31250 | 0.31250 | 0.37500 | 0.0436681 |
66 | E | H | 0.00000 | 0.00000 | 0.1076250 | 0.12500 | 0.12500 | 0.25000 | 0.0873362 |
67 | E | I | 0.00000 | 0.00000 | 0.0723750 | 0.06250 | 0.12500 | 0.25000 | 0.0752726 |
68 | E | J | 0.00000 | 0.00000 | 0.0592500 | 0.00000 | 0.12500 | 0.25000 | 0.0751754 |
69 | E | K | 0.00000 | 0.00000 | 0.0290000 | 0.00000 | 0.00000 | 0.12500 | 0.0527900 |
70 | E | L | 0.00000 | 0.00000 | 0.0683125 | 0.06250 | 0.12500 | 0.18750 | 0.0553799 |
71 | E | M | 0.00000 | 0.00000 | 0.0427500 | 0.00000 | 0.12500 | 0.12500 | 0.0593271 |
72 | E | N | 0.00000 | 0.00000 | 0.0563750 | 0.00000 | 0.12500 | 0.25000 | 0.0728804 |
74 | E | P | 0.00000 | 0.00000 | 0.0213750 | 0.00000 | 0.06250 | 0.06250 | 0.0296636 |
75 | E | Q | 0.00000 | 0.00000 | 0.0427500 | 0.00000 | 0.12500 | 0.12500 | 0.0593271 |
76 | F | F | 0.50000 | 0.50000 | 0.5538125 | 0.56250 | 0.56250 | 0.62500 | 0.0436681 |
77 | F | G | 0.25000 | 0.25000 | 0.3038125 | 0.31250 | 0.31250 | 0.37500 | 0.0436681 |
78 | F | H | 0.12500 | 0.12500 | 0.1788125 | 0.18750 | 0.18750 | 0.25000 | 0.0436681 |
79 | F | I | 0.06250 | 0.06250 | 0.1243437 | 0.12500 | 0.15625 | 0.25000 | 0.0469043 |
80 | F | J | 0.00000 | 0.00000 | 0.0809375 | 0.06250 | 0.12500 | 0.25000 | 0.0678680 |
81 | F | K | 0.00000 | 0.00000 | 0.0360000 | 0.00000 | 0.06250 | 0.12500 | 0.0441377 |
82 | F | L | 0.06250 | 0.06250 | 0.1074062 | 0.09375 | 0.12500 | 0.18750 | 0.0327921 |
83 | F | M | 0.06250 | 0.06250 | 0.0838750 | 0.06250 | 0.12500 | 0.12500 | 0.0296636 |
84 | F | N | 0.00000 | 0.00000 | 0.0804375 | 0.06250 | 0.12500 | 0.25000 | 0.0667250 |
86 | F | P | 0.03125 | 0.03125 | 0.0419375 | 0.03125 | 0.06250 | 0.06250 | 0.0148318 |
87 | F | Q | 0.06250 | 0.06250 | 0.0838750 | 0.06250 | 0.12500 | 0.12500 | 0.0296636 |
88 | G | G | 0.50000 | 0.50000 | 0.5538125 | 0.56250 | 0.56250 | 0.62500 | 0.0436681 |
89 | G | H | 0.12500 | 0.12500 | 0.1788125 | 0.18750 | 0.18750 | 0.25000 | 0.0436681 |
90 | G | I | 0.06250 | 0.06250 | 0.1243437 | 0.12500 | 0.15625 | 0.25000 | 0.0469043 |
91 | G | J | 0.00000 | 0.00000 | 0.0809375 | 0.06250 | 0.12500 | 0.25000 | 0.0678680 |
92 | G | K | 0.00000 | 0.00000 | 0.0360000 | 0.00000 | 0.06250 | 0.12500 | 0.0441377 |
93 | G | L | 0.06250 | 0.06250 | 0.1074062 | 0.09375 | 0.12500 | 0.18750 | 0.0327921 |
94 | G | M | 0.06250 | 0.06250 | 0.0838750 | 0.06250 | 0.12500 | 0.12500 | 0.0296636 |
95 | G | N | 0.00000 | 0.00000 | 0.0804375 | 0.06250 | 0.12500 | 0.25000 | 0.0667250 |
97 | G | P | 0.03125 | 0.03125 | 0.0419375 | 0.03125 | 0.06250 | 0.06250 | 0.0148318 |
98 | G | Q | 0.06250 | 0.06250 | 0.0838750 | 0.06250 | 0.12500 | 0.12500 | 0.0296636 |
100 | H | I | 0.12500 | 0.12500 | 0.1763125 | 0.18750 | 0.18750 | 0.25000 | 0.0426388 |
101 | H | J | 0.00000 | 0.00000 | 0.1026250 | 0.12500 | 0.12500 | 0.25000 | 0.0852775 |
102 | H | K | 0.00000 | 0.00000 | 0.0430000 | 0.00000 | 0.12500 | 0.12500 | 0.0594098 |
103 | H | L | 0.12500 | 0.12500 | 0.1465000 | 0.12500 | 0.18750 | 0.18750 | 0.0297049 |
105 | H | N | 0.00000 | 0.00000 | 0.1045000 | 0.12500 | 0.12500 | 0.25000 | 0.0867455 |
109 | I | I | 0.50000 | 0.50000 | 0.5402500 | 0.50000 | 0.62500 | 0.62500 | 0.0584346 |
110 | I | J | 0.25000 | 0.25000 | 0.2902500 | 0.25000 | 0.37500 | 0.37500 | 0.0584346 |
111 | I | K | 0.00000 | 0.00000 | 0.0555625 | 0.00000 | 0.12500 | 0.18750 | 0.0686899 |
112 | I | L | 0.06250 | 0.06250 | 0.1159375 | 0.09375 | 0.12500 | 0.21875 | 0.0409078 |
113 | I | M | 0.12500 | 0.12500 | 0.1451250 | 0.12500 | 0.18750 | 0.18750 | 0.0292173 |
114 | I | N | 0.00000 | 0.00000 | 0.0713750 | 0.06250 | 0.12500 | 0.25000 | 0.0740365 |
116 | I | P | 0.06250 | 0.06250 | 0.0725625 | 0.06250 | 0.09375 | 0.09375 | 0.0146086 |
117 | I | Q | 0.12500 | 0.12500 | 0.1451250 | 0.12500 | 0.18750 | 0.18750 | 0.0292173 |
119 | J | K | 0.00000 | 0.00000 | 0.0251250 | 0.00000 | 0.00000 | 0.12500 | 0.0501186 |
120 | J | L | 0.00000 | 0.00000 | 0.0638750 | 0.06250 | 0.12500 | 0.18750 | 0.0518488 |
121 | J | M | 0.00000 | 0.00000 | 0.0402500 | 0.00000 | 0.12500 | 0.12500 | 0.0584346 |
122 | J | N | 0.00000 | 0.00000 | 0.0585000 | 0.00000 | 0.12500 | 0.25000 | 0.0749307 |
124 | J | P | 0.00000 | 0.00000 | 0.0201250 | 0.00000 | 0.06250 | 0.06250 | 0.0292173 |
125 | J | Q | 0.00000 | 0.00000 | 0.0402500 | 0.00000 | 0.12500 | 0.12500 | 0.0584346 |
127 | K | L | 0.25000 | 0.25000 | 0.2715000 | 0.25000 | 0.31250 | 0.31250 | 0.0297049 |
128 | K | M | 0.00000 | 0.00000 | 0.0430000 | 0.00000 | 0.12500 | 0.12500 | 0.0594098 |
129 | K | N | 0.00000 | 0.00000 | 0.0291250 | 0.00000 | 0.00000 | 0.12500 | 0.0528692 |
131 | K | P | 0.00000 | 0.00000 | 0.0215000 | 0.00000 | 0.06250 | 0.06250 | 0.0297049 |
132 | K | Q | 0.00000 | 0.00000 | 0.0430000 | 0.00000 | 0.12500 | 0.12500 | 0.0594098 |
133 | L | L | 0.50000 | 0.50000 | 0.5215000 | 0.50000 | 0.56250 | 0.56250 | 0.0297049 |
134 | L | M | 0.06250 | 0.06250 | 0.0840000 | 0.06250 | 0.12500 | 0.12500 | 0.0297049 |
135 | L | N | 0.00000 | 0.00000 | 0.0668125 | 0.06250 | 0.12500 | 0.18750 | 0.0540901 |
137 | L | P | 0.03125 | 0.03125 | 0.0420000 | 0.03125 | 0.06250 | 0.06250 | 0.0148525 |
138 | L | Q | 0.06250 | 0.06250 | 0.0840000 | 0.06250 | 0.12500 | 0.12500 | 0.0297049 |
140 | M | N | 0.00000 | 0.00000 | 0.0421250 | 0.00000 | 0.12500 | 0.12500 | 0.0591152 |
146 | N | P | 0.00000 | 0.00000 | 0.0210625 | 0.00000 | 0.06250 | 0.06250 | 0.0295576 |
147 | N | Q | 0.00000 | 0.00000 | 0.0421250 | 0.00000 | 0.12500 | 0.12500 | 0.0591152 |
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, ]
if (any(stats_short$id_1 != stats_long$id_1) ||
any(stats_short$id_2 != stats_long$id_2)) {
cat("At least one row represents a different animal pair")
}
comprison <- data.frame(
id_1 = stats_short$id_1,
id_2 = stats_short$id_2,
meanKin_short = stats_short$mean,
meanKin_long = stats_long$mean,
meanKinDelta = abs(stats_short$mean - stats_long$mean),
sdKin_short = stats_short$sd,
sdKin_long = stats_long$sd,
sdKinDelta = abs(stats_short$sd - stats_long$sd)
)
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.0500 | 0.0855 | 0.0355 | 0.1054 | 0.1187 | 0.0132 |
A | F | 0.1500 | 0.1677 | 0.0177 | 0.0527 | 0.0593 | 0.0066 |
A | G | 0.1500 | 0.1677 | 0.0177 | 0.0527 | 0.0593 | 0.0066 |
A | I | 0.3000 | 0.2902 | 0.0098 | 0.0645 | 0.0584 | 0.0061 |
A | J | 0.1000 | 0.0805 | 0.0195 | 0.1291 | 0.1169 | 0.0122 |
A | K | 0.0500 | 0.0860 | 0.0360 | 0.1054 | 0.1188 | 0.0134 |
A | L | 0.1500 | 0.1680 | 0.0180 | 0.0527 | 0.0594 | 0.0067 |
A | N | 0.0750 | 0.0843 | 0.0093 | 0.1208 | 0.1182 | 0.0025 |
B | E | 0.0750 | 0.1297 | 0.0547 | 0.1208 | 0.1250 | 0.0042 |
B | F | 0.1625 | 0.1899 | 0.0274 | 0.0604 | 0.0625 | 0.0021 |
B | G | 0.1625 | 0.1899 | 0.0274 | 0.0604 | 0.0625 | 0.0021 |
B | I | 0.0875 | 0.0624 | 0.0251 | 0.0604 | 0.0625 | 0.0022 |
B | J | 0.1750 | 0.1248 | 0.0502 | 0.1208 | 0.1251 | 0.0043 |
B | N | 0.1000 | 0.1248 | 0.0248 | 0.1291 | 0.1251 | 0.0040 |
C | E | 0.0625 | 0.1076 | 0.0451 | 0.0884 | 0.0873 | 0.0011 |
C | F | 0.1562 | 0.1788 | 0.0226 | 0.0442 | 0.0437 | 0.0005 |
C | G | 0.1562 | 0.1788 | 0.0226 | 0.0442 | 0.0437 | 0.0005 |
C | I | 0.1938 | 0.1763 | 0.0174 | 0.0198 | 0.0426 | 0.0229 |
C | J | 0.1375 | 0.1026 | 0.0349 | 0.0395 | 0.0853 | 0.0457 |
C | K | 0.0250 | 0.0430 | 0.0180 | 0.0527 | 0.0594 | 0.0067 |
C | L | 0.2625 | 0.2715 | 0.0090 | 0.0264 | 0.0297 | 0.0034 |
C | N | 0.0875 | 0.1045 | 0.0170 | 0.0604 | 0.0867 | 0.0264 |
D | E | 0.0625 | 0.1076 | 0.0451 | 0.0884 | 0.0873 | 0.0011 |
D | F | 0.2812 | 0.3038 | 0.0226 | 0.0442 | 0.0437 | 0.0005 |
D | G | 0.2812 | 0.3038 | 0.0226 | 0.0442 | 0.0437 | 0.0005 |
D | I | 0.1938 | 0.1763 | 0.0174 | 0.0198 | 0.0426 | 0.0229 |
D | J | 0.1375 | 0.1026 | 0.0349 | 0.0395 | 0.0853 | 0.0457 |
D | K | 0.0250 | 0.0430 | 0.0180 | 0.0527 | 0.0594 | 0.0067 |
D | L | 0.1375 | 0.1465 | 0.0090 | 0.0264 | 0.0297 | 0.0034 |
D | N | 0.0875 | 0.1045 | 0.0170 | 0.0604 | 0.0867 | 0.0264 |
E | F | 0.2812 | 0.3038 | 0.0226 | 0.0442 | 0.0437 | 0.0005 |
E | G | 0.2812 | 0.3038 | 0.0226 | 0.0442 | 0.0437 | 0.0005 |
E | H | 0.0625 | 0.1076 | 0.0451 | 0.0884 | 0.0873 | 0.0011 |
E | I | 0.0562 | 0.0724 | 0.0161 | 0.0748 | 0.0753 | 0.0004 |
E | J | 0.0625 | 0.0593 | 0.0032 | 0.0659 | 0.0752 | 0.0093 |
E | K | 0.0125 | 0.0290 | 0.0165 | 0.0395 | 0.0528 | 0.0133 |
E | L | 0.0375 | 0.0683 | 0.0308 | 0.0437 | 0.0554 | 0.0117 |
E | M | 0.0250 | 0.0427 | 0.0177 | 0.0527 | 0.0593 | 0.0066 |
E | N | 0.0500 | 0.0564 | 0.0064 | 0.0645 | 0.0729 | 0.0083 |
E | P | 0.0125 | 0.0214 | 0.0089 | 0.0264 | 0.0297 | 0.0033 |
E | Q | 0.0250 | 0.0427 | 0.0177 | 0.0527 | 0.0593 | 0.0066 |
F | F | 0.5312 | 0.5538 | 0.0226 | 0.0442 | 0.0437 | 0.0005 |
F | G | 0.2812 | 0.3038 | 0.0226 | 0.0442 | 0.0437 | 0.0005 |
F | H | 0.1562 | 0.1788 | 0.0226 | 0.0442 | 0.0437 | 0.0005 |
F | I | 0.1250 | 0.1243 | 0.0007 | 0.0361 | 0.0469 | 0.0108 |
F | J | 0.1000 | 0.0809 | 0.0191 | 0.0323 | 0.0679 | 0.0356 |
F | K | 0.0187 | 0.0360 | 0.0172 | 0.0302 | 0.0441 | 0.0139 |
F | L | 0.0875 | 0.1074 | 0.0199 | 0.0198 | 0.0328 | 0.0130 |
F | M | 0.0750 | 0.0839 | 0.0089 | 0.0264 | 0.0297 | 0.0033 |
F | N | 0.0688 | 0.0804 | 0.0117 | 0.0461 | 0.0667 | 0.0206 |
F | P | 0.0375 | 0.0419 | 0.0044 | 0.0132 | 0.0148 | 0.0017 |
F | Q | 0.0750 | 0.0839 | 0.0089 | 0.0264 | 0.0297 | 0.0033 |
G | G | 0.5312 | 0.5538 | 0.0226 | 0.0442 | 0.0437 | 0.0005 |
G | H | 0.1562 | 0.1788 | 0.0226 | 0.0442 | 0.0437 | 0.0005 |
G | I | 0.1250 | 0.1243 | 0.0007 | 0.0361 | 0.0469 | 0.0108 |
G | J | 0.1000 | 0.0809 | 0.0191 | 0.0323 | 0.0679 | 0.0356 |
G | K | 0.0187 | 0.0360 | 0.0172 | 0.0302 | 0.0441 | 0.0139 |
G | L | 0.0875 | 0.1074 | 0.0199 | 0.0198 | 0.0328 | 0.0130 |
G | M | 0.0750 | 0.0839 | 0.0089 | 0.0264 | 0.0297 | 0.0033 |
G | N | 0.0688 | 0.0804 | 0.0117 | 0.0461 | 0.0667 | 0.0206 |
G | P | 0.0375 | 0.0419 | 0.0044 | 0.0132 | 0.0148 | 0.0017 |
G | Q | 0.0750 | 0.0839 | 0.0089 | 0.0264 | 0.0297 | 0.0033 |
H | I | 0.1938 | 0.1763 | 0.0174 | 0.0198 | 0.0426 | 0.0229 |
H | J | 0.1375 | 0.1026 | 0.0349 | 0.0395 | 0.0853 | 0.0457 |
H | K | 0.0250 | 0.0430 | 0.0180 | 0.0527 | 0.0594 | 0.0067 |
H | L | 0.1375 | 0.1465 | 0.0090 | 0.0264 | 0.0297 | 0.0034 |
H | N | 0.0875 | 0.1045 | 0.0170 | 0.0604 | 0.0867 | 0.0264 |
I | I | 0.5500 | 0.5402 | 0.0098 | 0.0645 | 0.0584 | 0.0061 |
I | J | 0.3000 | 0.2902 | 0.0098 | 0.0645 | 0.0584 | 0.0061 |
I | K | 0.0375 | 0.0556 | 0.0181 | 0.0672 | 0.0687 | 0.0015 |
I | L | 0.1156 | 0.1159 | 0.0003 | 0.0331 | 0.0409 | 0.0078 |
I | M | 0.1500 | 0.1451 | 0.0049 | 0.0323 | 0.0292 | 0.0031 |
I | N | 0.0688 | 0.0714 | 0.0026 | 0.0688 | 0.0740 | 0.0053 |
I | P | 0.0750 | 0.0726 | 0.0024 | 0.0161 | 0.0146 | 0.0015 |
I | Q | 0.1500 | 0.1451 | 0.0049 | 0.0323 | 0.0292 | 0.0031 |
J | K | 0.0250 | 0.0251 | 0.0001 | 0.0527 | 0.0501 | 0.0026 |
J | L | 0.0813 | 0.0639 | 0.0174 | 0.0302 | 0.0518 | 0.0217 |
J | M | 0.0500 | 0.0402 | 0.0098 | 0.0645 | 0.0584 | 0.0061 |
J | N | 0.0625 | 0.0585 | 0.0040 | 0.0884 | 0.0749 | 0.0135 |
J | P | 0.0250 | 0.0201 | 0.0049 | 0.0323 | 0.0292 | 0.0031 |
J | Q | 0.0500 | 0.0402 | 0.0098 | 0.0645 | 0.0584 | 0.0061 |
K | L | 0.2625 | 0.2715 | 0.0090 | 0.0264 | 0.0297 | 0.0034 |
K | M | 0.0250 | 0.0430 | 0.0180 | 0.0527 | 0.0594 | 0.0067 |
K | N | 0.0125 | 0.0291 | 0.0166 | 0.0395 | 0.0529 | 0.0133 |
K | P | 0.0125 | 0.0215 | 0.0090 | 0.0264 | 0.0297 | 0.0034 |
K | Q | 0.0250 | 0.0430 | 0.0180 | 0.0527 | 0.0594 | 0.0067 |
L | L | 0.5125 | 0.5215 | 0.0090 | 0.0264 | 0.0297 | 0.0034 |
L | M | 0.0750 | 0.0840 | 0.0090 | 0.0264 | 0.0297 | 0.0034 |
L | N | 0.0500 | 0.0668 | 0.0168 | 0.0264 | 0.0541 | 0.0277 |
L | P | 0.0375 | 0.0420 | 0.0045 | 0.0132 | 0.0149 | 0.0017 |
L | Q | 0.0750 | 0.0840 | 0.0090 | 0.0264 | 0.0297 | 0.0034 |
M | N | 0.0375 | 0.0421 | 0.0046 | 0.0604 | 0.0591 | 0.0013 |
N | P | 0.0187 | 0.0211 | 0.0023 | 0.0302 | 0.0296 | 0.0006 |
N | Q | 0.0375 | 0.0421 | 0.0046 | 0.0604 | 0.0591 | 0.0013 |
stats_short <- stats_100[stats_100$sd > 0.0, ]
stats_long <- stats_1000[stats_1000$sd > 0.0, ]
if (any(stats_short$id_1 != stats_long$id_1) ||
any(stats_short$id_2 != stats_long$id_2)) {
cat("At least one row represents a different animal pair")
}
comprison <- data.frame(
id_1 = stats_short$id_1,
id_2 = stats_short$id_2,
meanKin_short = stats_short$mean,
meanKin_long = stats_long$mean,
meanKinDelta = abs(stats_short$mean - stats_long$mean),
sdKin_short = stats_short$sd,
sdKin_long = stats_long$sd,
sdKinDelta = abs(stats_short$sd - stats_long$sd)
)
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.1000 | 0.0855 | 0.0145 | 0.1231 | 0.1187 | 0.0044 |
A | F | 0.1750 | 0.1677 | 0.0073 | 0.0615 | 0.0593 | 0.0022 |
A | G | 0.1750 | 0.1677 | 0.0073 | 0.0615 | 0.0593 | 0.0022 |
A | I | 0.2875 | 0.2902 | 0.0027 | 0.0576 | 0.0584 | 0.0009 |
A | J | 0.0750 | 0.0805 | 0.0055 | 0.1151 | 0.1169 | 0.0017 |
A | K | 0.0700 | 0.0860 | 0.0160 | 0.1128 | 0.1188 | 0.0060 |
A | L | 0.1600 | 0.1680 | 0.0080 | 0.0564 | 0.0594 | 0.0030 |
A | N | 0.0725 | 0.0843 | 0.0118 | 0.1140 | 0.1182 | 0.0042 |
B | E | 0.1350 | 0.1297 | 0.0053 | 0.1252 | 0.1250 | 0.0003 |
B | F | 0.1925 | 0.1899 | 0.0026 | 0.0626 | 0.0625 | 0.0001 |
B | G | 0.1925 | 0.1899 | 0.0026 | 0.0626 | 0.0625 | 0.0001 |
B | I | 0.0588 | 0.0624 | 0.0036 | 0.0627 | 0.0625 | 0.0002 |
B | J | 0.1175 | 0.1248 | 0.0073 | 0.1254 | 0.1251 | 0.0003 |
B | N | 0.1225 | 0.1248 | 0.0023 | 0.1256 | 0.1251 | 0.0005 |
C | E | 0.1175 | 0.1076 | 0.0099 | 0.0970 | 0.0873 | 0.0097 |
C | F | 0.1837 | 0.1788 | 0.0049 | 0.0485 | 0.0437 | 0.0048 |
C | G | 0.1837 | 0.1788 | 0.0049 | 0.0485 | 0.0437 | 0.0048 |
C | I | 0.1731 | 0.1763 | 0.0032 | 0.0396 | 0.0426 | 0.0031 |
C | J | 0.0963 | 0.1026 | 0.0064 | 0.0792 | 0.0853 | 0.0061 |
C | K | 0.0350 | 0.0430 | 0.0080 | 0.0564 | 0.0594 | 0.0030 |
C | L | 0.2675 | 0.2715 | 0.0040 | 0.0282 | 0.0297 | 0.0015 |
C | N | 0.0975 | 0.1045 | 0.0070 | 0.0786 | 0.0867 | 0.0081 |
D | E | 0.1175 | 0.1076 | 0.0099 | 0.0970 | 0.0873 | 0.0097 |
D | F | 0.3087 | 0.3038 | 0.0049 | 0.0485 | 0.0437 | 0.0048 |
D | G | 0.3087 | 0.3038 | 0.0049 | 0.0485 | 0.0437 | 0.0048 |
D | I | 0.1731 | 0.1763 | 0.0032 | 0.0396 | 0.0426 | 0.0031 |
D | J | 0.0963 | 0.1026 | 0.0064 | 0.0792 | 0.0853 | 0.0061 |
D | K | 0.0350 | 0.0430 | 0.0080 | 0.0564 | 0.0594 | 0.0030 |
D | L | 0.1425 | 0.1465 | 0.0040 | 0.0282 | 0.0297 | 0.0015 |
D | N | 0.0975 | 0.1045 | 0.0070 | 0.0786 | 0.0867 | 0.0081 |
E | F | 0.3087 | 0.3038 | 0.0049 | 0.0485 | 0.0437 | 0.0048 |
E | G | 0.3087 | 0.3038 | 0.0049 | 0.0485 | 0.0437 | 0.0048 |
E | H | 0.1175 | 0.1076 | 0.0099 | 0.0970 | 0.0873 | 0.0097 |
E | I | 0.0813 | 0.0724 | 0.0089 | 0.0792 | 0.0753 | 0.0039 |
E | J | 0.0625 | 0.0593 | 0.0032 | 0.0743 | 0.0752 | 0.0009 |
E | K | 0.0275 | 0.0290 | 0.0015 | 0.0520 | 0.0528 | 0.0007 |
E | L | 0.0725 | 0.0683 | 0.0042 | 0.0587 | 0.0554 | 0.0034 |
E | M | 0.0500 | 0.0427 | 0.0073 | 0.0615 | 0.0593 | 0.0022 |
E | N | 0.0625 | 0.0564 | 0.0061 | 0.0764 | 0.0729 | 0.0035 |
E | P | 0.0250 | 0.0214 | 0.0036 | 0.0308 | 0.0297 | 0.0011 |
E | Q | 0.0500 | 0.0427 | 0.0073 | 0.0615 | 0.0593 | 0.0022 |
F | F | 0.5588 | 0.5538 | 0.0049 | 0.0485 | 0.0437 | 0.0048 |
F | G | 0.3087 | 0.3038 | 0.0049 | 0.0485 | 0.0437 | 0.0048 |
F | H | 0.1837 | 0.1788 | 0.0049 | 0.0485 | 0.0437 | 0.0048 |
F | I | 0.1272 | 0.1243 | 0.0028 | 0.0479 | 0.0469 | 0.0010 |
F | J | 0.0794 | 0.0809 | 0.0016 | 0.0640 | 0.0679 | 0.0039 |
F | K | 0.0312 | 0.0360 | 0.0047 | 0.0440 | 0.0441 | 0.0002 |
F | L | 0.1075 | 0.1074 | 0.0001 | 0.0345 | 0.0328 | 0.0017 |
F | M | 0.0875 | 0.0839 | 0.0036 | 0.0308 | 0.0297 | 0.0011 |
F | N | 0.0800 | 0.0804 | 0.0004 | 0.0635 | 0.0667 | 0.0032 |
F | P | 0.0438 | 0.0419 | 0.0018 | 0.0154 | 0.0148 | 0.0006 |
F | Q | 0.0875 | 0.0839 | 0.0036 | 0.0308 | 0.0297 | 0.0011 |
G | G | 0.5588 | 0.5538 | 0.0049 | 0.0485 | 0.0437 | 0.0048 |
G | H | 0.1837 | 0.1788 | 0.0049 | 0.0485 | 0.0437 | 0.0048 |
G | I | 0.1272 | 0.1243 | 0.0028 | 0.0479 | 0.0469 | 0.0010 |
G | J | 0.0794 | 0.0809 | 0.0016 | 0.0640 | 0.0679 | 0.0039 |
G | K | 0.0312 | 0.0360 | 0.0047 | 0.0440 | 0.0441 | 0.0002 |
G | L | 0.1075 | 0.1074 | 0.0001 | 0.0345 | 0.0328 | 0.0017 |
G | M | 0.0875 | 0.0839 | 0.0036 | 0.0308 | 0.0297 | 0.0011 |
G | N | 0.0800 | 0.0804 | 0.0004 | 0.0635 | 0.0667 | 0.0032 |
G | P | 0.0438 | 0.0419 | 0.0018 | 0.0154 | 0.0148 | 0.0006 |
G | Q | 0.0875 | 0.0839 | 0.0036 | 0.0308 | 0.0297 | 0.0011 |
H | I | 0.1731 | 0.1763 | 0.0032 | 0.0396 | 0.0426 | 0.0031 |
H | J | 0.0963 | 0.1026 | 0.0064 | 0.0792 | 0.0853 | 0.0061 |
H | K | 0.0350 | 0.0430 | 0.0080 | 0.0564 | 0.0594 | 0.0030 |
H | L | 0.1425 | 0.1465 | 0.0040 | 0.0282 | 0.0297 | 0.0015 |
H | N | 0.0975 | 0.1045 | 0.0070 | 0.0786 | 0.0867 | 0.0081 |
I | I | 0.5375 | 0.5402 | 0.0027 | 0.0576 | 0.0584 | 0.0009 |
I | J | 0.2875 | 0.2902 | 0.0027 | 0.0576 | 0.0584 | 0.0009 |
I | K | 0.0481 | 0.0556 | 0.0074 | 0.0658 | 0.0687 | 0.0029 |
I | L | 0.1106 | 0.1159 | 0.0053 | 0.0383 | 0.0409 | 0.0026 |
I | M | 0.1437 | 0.1451 | 0.0014 | 0.0288 | 0.0292 | 0.0004 |
I | N | 0.0662 | 0.0714 | 0.0051 | 0.0652 | 0.0740 | 0.0089 |
I | P | 0.0719 | 0.0726 | 0.0007 | 0.0144 | 0.0146 | 0.0002 |
I | Q | 0.1437 | 0.1451 | 0.0014 | 0.0288 | 0.0292 | 0.0004 |
J | K | 0.0262 | 0.0251 | 0.0011 | 0.0512 | 0.0501 | 0.0011 |
J | L | 0.0612 | 0.0639 | 0.0026 | 0.0478 | 0.0518 | 0.0040 |
J | M | 0.0375 | 0.0402 | 0.0027 | 0.0576 | 0.0584 | 0.0009 |
J | N | 0.0600 | 0.0585 | 0.0015 | 0.0721 | 0.0749 | 0.0028 |
J | P | 0.0187 | 0.0201 | 0.0014 | 0.0288 | 0.0292 | 0.0004 |
J | Q | 0.0375 | 0.0402 | 0.0027 | 0.0576 | 0.0584 | 0.0009 |
K | L | 0.2675 | 0.2715 | 0.0040 | 0.0282 | 0.0297 | 0.0015 |
K | M | 0.0350 | 0.0430 | 0.0080 | 0.0564 | 0.0594 | 0.0030 |
K | N | 0.0200 | 0.0291 | 0.0091 | 0.0461 | 0.0529 | 0.0068 |
K | P | 0.0175 | 0.0215 | 0.0040 | 0.0282 | 0.0297 | 0.0015 |
K | Q | 0.0350 | 0.0430 | 0.0080 | 0.0564 | 0.0594 | 0.0030 |
L | L | 0.5175 | 0.5215 | 0.0040 | 0.0282 | 0.0297 | 0.0015 |
L | M | 0.0800 | 0.0840 | 0.0040 | 0.0282 | 0.0297 | 0.0015 |
L | N | 0.0587 | 0.0668 | 0.0081 | 0.0460 | 0.0541 | 0.0081 |
L | P | 0.0400 | 0.0420 | 0.0020 | 0.0141 | 0.0149 | 0.0008 |
L | Q | 0.0800 | 0.0840 | 0.0040 | 0.0282 | 0.0297 | 0.0015 |
M | N | 0.0363 | 0.0421 | 0.0059 | 0.0570 | 0.0591 | 0.0021 |
N | P | 0.0181 | 0.0211 | 0.0029 | 0.0285 | 0.0296 | 0.0011 |
N | Q | 0.0363 | 0.0421 | 0.0059 | 0.0570 | 0.0591 | 0.0021 |
Add ability to use timestamped transactional location data to identify potential parents for animals with a missing parent.↩︎
This example is not realistic and particularly unrealistic with regard to potential dams. While it is possible for two animals to be switched near the time of birth so that dam and sire are not know with certainty and still have a limited number of potential parents. This is not a common occurrence in colonies of which we are aware.↩︎