Abstract
In many areas of computational biology, hidden Markov models (HMMs) have been used to model local genomic features. In particular, coalescent HMMs have been used to infer ancient population sizes, migration rates, divergence times, and other parameters such as mutation and recombination rates. As more loci, sequences, and hidden states are added to the model, however, the runtime of coalescent HMMs can quickly become prohibitive. Here we present a new algorithm for reducing the runtime of coalescent HMMs from quadratic in the number of hidden time states to linear, without making any additional approximations. Our algorithm can be incorporated into various coalescent HMMs, including the popular method PSMC for inferring variable effective population sizes. Here we implement this algorithm to speed up our demographic inference method diCal, which is equivalent to PSMC when applied to a sample of two haplotypes. We demonstrate that the linear-time method can reconstruct a population size change history more accurately than the quadratic-time method, given similar computation resources. We also apply the method to data from the 1000 Genomes project, inferring a high-resolution history of size changes in the European population.
Introduction
To understand how ancient populations grew, shrank, or migrated, biologists use coalescent HMMs. These models analyze DNA sequences to estimate the "Time to Most Recent Common Ancestor" (TMRCA) across different regions of the genome. Because the space of possible ancestral trees is infinite, researchers must discretize time into $d$ number of intervals.
Historically, standard algorithms for these HMMs have a computational complexity of $O(d^2)$. This quadratic scaling creates a significant bottleneck: doubling the time resolution quadruples the processing time. This has forced researchers to use coarse time "bins," which can blur or entirely miss rapid demographic shifts, such as sudden population crashes or bottlenecks.
Methodology: Exploiting Symmetries for Linear-Time Decoding
The core innovation of this research is a method to compute forward-backward probabilities and Expectation-Maximization (EM) updates in $O(d)$ time. This is achieved by exploiting the natural symmetries of the coalescent process.
When a DNA lineage undergoes recombination, it "breaks off" and "floats" back in time until it finds a new lineage to coalesce with. The authors realized that many of the transitions between hidden states in the HMM share identical probabilities because of this "floating" mechanic.
By using an augmented HMM that explicitly tracks these "floating" states, the transition matrix can be factored. Instead of summing over every possible pair of time intervals (the quadratic step), the algorithm uses a recursive approach that only requires a single pass through the time states.
Crucially, this is an exact computation; no approximations are made to achieve this speedup. Furthermore, by decomposing the EM objective function into a sum of terms, the researchers turned a complex multivariate optimization problem into a sequence of simpler univariate problems, improving convergence and avoiding local maxima.
Key Results
The researchers evaluated their algorithm using both simulated data and real-world data from the 1000 Genomes Project.
- Massive Speedup: In benchmarks with 128 time intervals, the linear-time method completed computations in a fraction of the time required by the quadratic method, which exhibited clear parabolic growth in runtime.
- The Resolution Dividend: The saved time can be "reinvested" into higher resolution. When given a fixed "time budget" of 40 hours, the linear-time method (using $d=21$) achieved an error rate of 0.079, nearly half the error of the quadratic method (0.148) which was restricted to $d=9$.
- Resolving the Bottleneck: Applying the method to 10 European (CEU) haplotypes from the 1000 Genomes project, the linear-time method clearly captured the "out-of-Africa" bottleneck. The quadratic method, limited by lower resolution, provided a much less characterized version of the same event.
Conclusion and Future Work
This linear-time algorithm allows for much higher-resolution reconstructions of ancient population histories without requiring massive increases in computing power. While the augmented HMM requires slightly more memory overhead, it provides a scalable path for analyzing thousands of genomes.
Future work will focus on extending this linear-time approach to more complex models that include migration and speciation (population splitting). Additionally, the authors aim to scale the method to handle samples of 30 or more haplotypes, which would provide even more power to resolve very recent historical events.
Summary updated