LinearSankoff: Linear-time Simultaneous Folding and Alignment of RNA Homologs

Sizhen Li, Ning Dai, He Zhang, Apoorv Malik, David H. Mathews, Liang HuangarXiv 2023

TL;DR

LinearSankoff is the first linear-time algorithm designed to simultaneously fold and align homologous RNA sequences, reducing computational complexity from $O(n^6)$ to $O(n)$. By integrating a Hidden Markov Model (HMM) alignment module with Synchronous Context-Free Grammars and beam search heuristics, it can process full-length viral genomes like SARS-CoV-2 (~30,000 nucleotides) in just 10 minutes—a task previously considered intractable.

What Problem Does This Paper Address?

Predicting the secondary structure of RNA is crucial for understanding its cellular functions, especially for viral genomes where structures are highly conserved even when the sequence mutates. The gold standard approach is the classical Sankoff algorithm, which simultaneously folds and aligns homologous sequences to leverage evolutionary information.

However, Sankoff suffers from two massive bottlenecks:

  1. Computational Intractability: The original algorithm scales at $O(n^6)$ for two sequences of length $n$. Even optimized versions that restrict the alignment space still scale at $O(n^3)$, making them far too slow for long sequences like the SARS-CoV-2 genome.
  2. Simplistic Alignment Models: Existing implementations use basic alignment models (like Needleman-Wunsch) that score matches, mismatches, and gaps independently, failing to capture complex evolutionary relationships like gap extensions.

Methods

The authors introduce LinearSankoff, which addresses these limitations through three core innovations:

  • Synchronous Context-Free Grammars (SCFG): Borrowing a concept from computational linguistics (originally used for joint parsing and machine translation of sentence pairs), the authors formally model simultaneous RNA folding and alignment as a synchronous derivation process.
  • HMM-Sankoff Integration: They seamlessly integrate a powerful HMM-based pairwise alignment model into the SCFG framework. This allows the dynamic programming algorithm to track hidden alignment states ($\nearrow, \rightarrow, \uparrow$), ensuring that gap extensions are penalized differently from gap openings.
  • Linearization via Beam Search and $A^\star$: To achieve $O(n)$ time complexity, LinearSankoff parses the sequences along the diagonal and applies a beam search heuristic, keeping only the top-$b$ highest-scoring states at each step. To prevent the beam from discarding the true optimal path, they incorporate an $A^\star$ search algorithm with admissible heuristics derived from pre-computed single-sequence folding and prefix/postfix Viterbi alignments.
Deductive system and beam pruning/A* heuristics in LinearSankoff

Datasets

The model was trained and evaluated using datasets from RNAStralign:

  • Training/Hyperparameter Tuning: 20 randomly sampled sequence pairs each from tRNA, 5S ribosomal RNA, tmRNA, and Group I Intron RNA.
  • Testing: 80 randomly sampled sequence pairs from SRP RNA, RNaseP RNA, telomerase RNA, and 16S rRNA.
  • Real-world Application: Full-length reference genomes of SARS-CoV-2 (NC_045512.2) and SARS-CoV-1 (NC_004718).

Key Insights and Ideas

  • The Linguistics Parallel: Homologous RNA folding is mathematically analogous to synchronous parsing in natural language processing. Treating structural alignment like machine translation provides a rigorous framework for joint modeling.
  • Mutual Benefit of Joint Modeling: Integrating a sophisticated HMM alignment model doesn't just improve alignment accuracy; it directly boosts structural prediction accuracy because the structural constraints guide the alignment, and vice versa.
  • Global Heuristics for Local Pruning: By using single-sequence folding and alignment bounds as an $A^\star$ heuristic, the algorithm can aggressively prune the search space during the beam search without sacrificing the quality of the final output.

Key Results

  • Linear Runtime Scaling: As shown in empirical benchmarks, while traditional tools like Dynalign scale cubically ($O(n^{2.8})$ empirically), LinearSankoff scales linearly ($O(n^{0.9})$ to $O(n^{1.0})$).
Runtime scaling comparison between Dynalign and LinearSankoff
  • Scalability to Viral Genomes: LinearSankoff successfully aligned and folded a pair of SARS-CoV-2 and SARS-related genomes (~30,000 nt) in roughly 10 minutes. Traditional cubic-time methods are completely intractable at this scale.
  • Superior Accuracy: On the RNAStralign test set, LinearSankoff achieved higher secondary structure prediction accuracy (F1 score) than all baselines (including LinearFold, Dynalign, FoldAlign, LocARNA, SCARNA, and LinearTurboFold).
  • Biological Discovery: LinearSankoff correctly aligned the conserved attenuator hairpin (AH) within the programmed $-1$ ribosomal frameshifting element (FSE) of SARS-CoV-1 and SARS-CoV-2, outperforming LinearTurboFold which failed to align it properly due to sequence-structure disagreements.

Limitations and Future Work

Currently, LinearSankoff is strictly a pairwise alignment and folding algorithm. While highly effective for two sequences, many comparative RNA analyses require looking at multiple homologous sequences simultaneously.

The authors note that LinearSankoff is in principle extendable to multiple sequences. They propose two future directions:

  1. Integrating it into a progressive alignment framework (like Multilign) to build consensus structures hierarchically.
  2. Generalizing the algorithm to take Multiple Sequence Alignments (MSAs) as inputs instead of single sequences, allowing it to progressively construct an MSA along a phylogenetic tree.

Summary updated

BibTeX
@misc{li2023linearsankoff,
  author = {Sizhen Li and Ning Dai and He Zhang and Apoorv Malik and David H. Mathews and Liang Huang},
  title = {{LinearSankoff: Linear-time Simultaneous Folding and Alignment of RNA Homologs}},
  year = {2023},
  eprint = {2307.09580},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.09580},
}
Figure