If we observe each generation, how can we measure the strength of drift? Use the same simulated cultures as the first notebook. The records contain complete population frequencies in generations 0–19. They have no additional genotype-sampling error, mutation, migration, or selection.
For parental frequency , define
Repeated cultures starting at the same let us estimate this conditional variance. One culture’s change alone does not provide it.
library(hpgR)
generation_records <- simulateFrequencyRecords()$records
Read the Generation Records¶
The code above regenerates the first notebook’s records with the same seed, so this notebook also runs independently. Rows are known generations and columns are independent cultures. Inspect the first six cultures.
options(repr.plot.width = 9, repr.plot.height = 4.2, repr.plot.pointsize = 13,
repr.plot.bg = "white")
invisible(par(bg = "white"))
blue <- "#265991"
red <- "#C73D28"
data.frame(generation = generation_records$generation[1:4],
generation_records$frequency[1:4, 1:6], check.names = FALSE)
Estimate the Copying Rate within a Frequency Class¶
Every culture starts at . Use the first recorded transition across cultures to estimate . Then . Later transitions have different parental frequencies and must be grouped by their starting frequency before applying this same calculation.
parent_frequency <- generation_records$frequency[1, ]
offspring_frequency <- generation_records$frequency[2, ]
estimate <- estimateFromGenerations(parent_frequency, offspring_frequency)
round(estimate, 5)
old_par <- par(mfrow = c(1, 2), mar = c(4, 4, 2, 1), bg = "white")
matplot(0:1, rbind(parent_frequency, offspring_frequency), type = "l",
col = grDevices::adjustcolor(blue, alpha.f = 0.35), lty = 1,
xlab = "Generation", ylab = "Allele frequency", xaxt = "n", ylim = c(0, 1))
axis(1, at = 0:1)
hist(offspring_frequency - parent_frequency, breaks = 12, col = blue, border = "white",
xlab = expression(p[1] - p[0]), main = "Changes across recorded cultures")
abline(v = 0, col = red, lty = 2)
par(old_par)

Compare with the Generating Size¶
The estimate used only the two recorded frequencies. Now reveal the known simulation size. Finite replication makes the estimated variance noisy. Buri’s experiment in the lecture uses the same variance-matching principle; these simulated records do not reproduce his observed estimates.
generating_N <- generation_records$generating_N
data.frame(
quantity = c("Conditional frequency variance", "Variance effective size"),
estimated = c(estimate["variance"], estimate["Ne_V"]),
generating_model = c(0.5 * 0.5 / (2 * generating_N), generating_N)
)
stopifnot(abs(var(offspring_frequency - parent_frequency) - var(offspring_frequency)) < 1e-12)
Sources: Pritchard, Sec. 2.1; Gorroochurn, Sec. 8.8; Buri (1956), Table 11 and Fig. 3. This calculation requires time-indexed frequencies. Lecture 9 estimates population parameters from sampled genetic data without these generation records.