Two populations can start with the same allele frequency and diverge by drift. Migration mixes their parental pools. Follow the resulting frequency gap and ask what happens when we pool genotypes from the two populations.
Drift after a split¶
Start two isolated populations at . Each diploid population has . Independent Wright–Fisher draws can widen the frequency gap in either direction. Across many pairs the signed gap should average close to zero.
library(hpgR)
options(repr.plot.width = 9, repr.plot.height = 4.5)
par(bg = "white")
Ne <- 100L
generations <- 30L
panels <- 100L
time <- 0:generations
set.seed(1010)
split_pairs <- replicate(panels,
simulateMigrationDrift(c(0.5, 0.5), Ne, m = 0, generations), simplify = FALSE)
split_gap <- vapply(split_pairs, function(p) p[, 1] - p[, 2], numeric(length(time)))
matplot(time, split_gap[, 1:12], type = "l", lty = 1, col = "grey55",
xlab = "Generation", ylab = "Frequency gap")
abline(h = 0, lty = 2)
stopifnot(all(abs(split_gap) <= 1))
Mix parental copies, then sample¶
Start at and . In each generation, a fraction of parental copies comes from the other population. For ,
With , the expected gap is . The deterministic recursion follows this line exactly. Finite-population paths wander around it.
Use 100 runs of 30 generations, with in each population and seed 1011. Compare the mean simulated gap and the first run with the model expectation.
start <- c(0.8, 0.2)
pi1 <- 0.05
frequency <- migrationFrequencies(start[1], start[2], m = pi1, generations = generations)
expected_gap <- frequency[, 1] - frequency[, 2]
stopifnot(isTRUE(all.equal(frequency[2, ], c("population 1" = 0.77,
"population 2" = 0.23))),
isTRUE(all.equal(rowMeans(frequency), rep(0.5, length(time)))),
isTRUE(all.equal(expected_gap, diff(rev(start)) * (1 - 2 * pi1)^time)))
set.seed(1011)
migration_pairs <- replicate(panels,
simulateMigrationDrift(start, Ne, m = pi1, generations = generations), simplify = FALSE)
migration_gap <- vapply(migration_pairs,
function(p) p[, 1] - p[, 2], numeric(length(time)))
mean_gap <- rowMeans(migration_gap)
first_gap <- migration_gap[, 1L]
plotGap <- function() {
previous <- par(mar = c(4, 4, 0.7, 0.8), mgp = c(2.6, 0.75, 0))
on.exit(par(previous))
plot(time, first_gap, type = "n", bty = "l", las = 1,
ylim = range(c(first_gap, expected_gap, mean_gap, 0)),
xlab = "Generation", ylab = "Allele frequency gap")
abline(h = 0, col = "grey85")
lines(time, first_gap, col = "grey55", lwd = 1.6)
lines(time, mean_gap, col = "#1D4F91", lwd = 2.5)
lines(time, expected_gap, col = "#B44A3A", lwd = 2.5, lty = 2)
legend("topright", c("Theory", "Simulation mean (100 runs)", "One simulated run"),
col = c("#B44A3A", "#1D4F91", "grey55"), lty = c(2, 1, 1),
lwd = c(2.5, 2.5, 1.6), bty = "n", cex = 0.95)
}
figure_dir <- Sys.getenv("P8149_FIGURE_DIR")
if (nzchar(figure_dir)) {
pdf(file.path(figure_dir, "migration_frequency_gap.pdf"), width = 8.2, height = 3.6)
tryCatch(plotGap(), finally = invisible(dev.off()))
}
plotGap()
rows <- c(1L, 2L, 3L, generations + 1L)
data.frame(generation = time[rows],
expected_gap = round(expected_gap[rows], 3),
simulated_mean_gap = round(mean_gap[rows], 3),
first_run_gap = round(first_gap[rows], 3))
The frequency gap sets differentiation¶
For two equally weighted populations, let , , and . Then . When stays fixed, is proportional to . In this deterministic calculation it shrinks by per generation.
A split-time calculation uses an ancestral reference. Suppose equal-sized isolated daughter populations of diploid size split generations ago. At small , the variance across daughter frequencies is approximately , where is the ancestral frequency. For this definition, dividing by gives . The calculation below uses the observed pooled frequency for its heterozygosity contrast (Pritchard, Sec. 2.4).
observed_fst <- pairwiseFst(frequency[, 1], frequency[, 2])
predicted_fst <- pairwiseFst(start[1], start[2]) * (1 - 2 * pi1)^(2 * time)
old_par <- par(mfrow = c(1, 2), mar = c(4, 4, 2, 1), bg = "white")
matplot(time, frequency, type = "l", lwd = 2, lty = 1,
col = c("#B44A3A", "#306C9A"), xlab = "Generation",
ylab = "Allele frequency", ylim = c(0, 1))
legend("topright", colnames(frequency), col = c("#B44A3A", "#306C9A"),
lty = 1, bty = "n", cex = 0.8, y.intersp = 1.7)
plot(time, observed_fst, type = "l", lwd = 2, col = "#5A547D",
xlab = "Generation", ylab = expression(F[ST]), ylim = c(0, 0.4))
lines(time, predicted_fst, lty = 2, lwd = 2)
legend("topright", c("Calculated", "From frequency gap"),
col = c("#5A547D", "black"), lty = c(1, 2), bty = "n", cex = 0.8, y.intersp = 1.7)
par(old_par)
stopifnot(isTRUE(all.equal(observed_fst, predicted_fst)))
Pooling creates a heterozygote deficit¶
Before migration, the pooled allele frequency is 0.5, so Hardy–Weinberg predicts . Each population has heterozygote frequency 0.32, so the observed heterozygote frequency after pooling is . This deficit under random mating within each population is the Wahlund effect.
p <- c(population_1 = 0.8, population_2 = 0.2)
pool <- poolAlleleFrequencies(p)
genotype <- pool$genotype
pooled <- pool$pooled
pooled_p <- pool$pooled_p
H_S <- pool$H_S
H_T <- pool$H_T
F_ST <- pool$F_ST
stopifnot(all(abs(colSums(genotype) - 1) < 1e-12))
stopifnot(abs(H_S - 0.32) < 1e-12, abs(H_T - 0.5) < 1e-12)
stopifnot(abs(F_ST - 0.36) < 1e-12)
c(within = H_S, pooled_HWE = H_T, F_ST = F_ST)old_par <- par(mfrow = c(1, 2), mar = c(4, 4, 1, 1))
barplot(genotype, beside = TRUE, col = c('#306C9A', '#E5AA49', '#B44A3A'),
names.arg = names(p), ylab = 'HWE genotype frequency')
legend('topright', legend = rownames(genotype),
fill = c('#306C9A', '#E5AA49', '#B44A3A'), bty = 'n', cex = 0.75, y.intersp = 1.7)
barplot(c(actual_pooled = H_S, HWE_at_pooled_p = H_T),
col = c('#306C9A', '#B44A3A'), ylim = c(0, 0.6),
ylab = 'Heterozygote frequency')
par(old_par)
Compare two differentiated loci¶
Apply the equal-weight formula to a SNP near EPAS1 (0.87 in Tibetans, 0.09 in Han Chinese) and to the fraction of dogs and wolves with more than two copies of AMY2B (354/392 and 1/51). The copy-number calculation uses a binary indicator.
frequency <- rbind(
EPAS1_SNP = c(population_1 = 0.87, population_2 = 0.09),
AMY2B_expansion = c(population_1 = 354 / 392, population_2 = 1 / 51)
)
result <- t(apply(frequency, 1, frequencyDifferentiation))
round(result, 3)stopifnot(abs(result['EPAS1_SNP', 'F_ST'] - 0.609375) < 1e-10)
stopifnot(abs(result['AMY2B_expansion', 'F_ST'] - 0.7851853) < 1e-6)
old_par <- par(mfrow = c(1, 2), mar = c(4, 4, 2, 1))
barplot(frequency['EPAS1_SNP', ], col = c('#306C9A', '#B44A3A'),
ylim = c(0, 1), names.arg = c('Tibetan', 'Han'),
ylab = 'Allele frequency', main = 'EPAS1 SNP')
barplot(frequency['AMY2B_expansion', ], col = c('#306C9A', '#B44A3A'),
ylim = c(0, 1), names.arg = c('Dogs', 'Wolves'),
ylab = 'Expansion frequency', main = 'AMY2B > 2 copies')
par(old_par)
The EPAS1 SNP and the AMY2B expansion give equal-weight differentiation summaries of about 0.61 and 0.79. The AMY2B input is the fraction of individuals above two copies. Shared haplotypes and archaic DNA will help trace the source of the EPAS1 variant.
Sources: Pritchard, Sec. 2.4; Gorroochurn, Secs. 8.2 and 9.2–9.4; Yi et al. (2010) and Arendt et al. (2016).
Next: Manhattan Rats and a Barrier to Migration. Geography adds a question: do pairs at the same distance show more genetic difference when a barrier separates them?