Pandedup: building a k-mer spectrum of HPRCv2

Ragnar {Groot Koerkamp}

Genome Informatics 2026, Hinxton

curiouscoding.nl/slides/pandedup github.com/RagnarGrootKoerkamp/pandedup

Previously on … Ragnar's talks:

Batching, Streaming, Prefetching

Today: multithreading

I have idle CPU cores, not idle walltime

What's in a k-mer spectrum (SPSS)

unitig.svg simplitig.svg
Unitigs Simplitigs
matchtig.svg masked.svg
Matchtigs Masked superstring

Overview

hprcv2-k31.svg

Overview

hprcv2-k63.svg

Quick & dirty: deduplicating the parse

Deduplicating overlapping minimizer phrases An example of the optional forward-reference pass. Lexicographic four-base minimizers anchor phrases with 14-base overlaps. Underlines show phrase spans. Assembly 2 has a seeded random substitution. Assembly 3 shares its first phrase with the reference. Two substitutions change its anchors and phrases, with non-emitted bases dimmed. Dashed underlines mark greedily matched phrases. Separate threads process Assemblies 2 and 3. The hash set schematic shows one colored dot per stored phrase hash and a lock for each illustrated shard. Dot colors identify the assembly that supplied the phrase. (k'=4, w=25)-minimizers Reference AAGCAATTCACGAGCTGCGGTCCAAATCGGGTAAGCCCTCCTTCGATGTGAACTACGGTTTGAGGCGATTTTCACATTTGTCCACTCAGGGAGGATGGACGCGCTAAGTCACAGAATATC Parse for k=15 phrase k-1=14 overlap Assembly 2 AAGCAATTCACGAGCTGCGGTCCAAATCGGGTAAGCCCTCCTTCGATCTGAACTACGGTTTGAGGCGATTTTCACATTTGTCCACTCAGGGAGGATGGACGCGCTAAGTCACAGAATATC Thread 1 Greedily matched Assembly 3 AAGCAATTCACGAGCTGCGGTCCAAATCGGGTAAGCCCTCCTTCGATGTGAACAACGGTTTGAGGCGATTTTCTCATTTGTCCACTCAGGGAGGATGGACGCGCTAAGTCACAGAATATC Thread 2 Sharded set of phrase hashes

MSS: BiGreedy via \(k\) rounds of 4-way merging

LF-based matching at overlaps of three through zero bases Eight simplitigs of length five through ten are listed by prefix in rainbow order at k equals four, using forward orientations. At each shorter overlap, the suffix keys lose their first base. Shading marks the retained bases in each already-sorted suffix range and in the prefix column. During the merge step, lines colored by source range connect each suffix to its next row. Gray shading marks the input prefixes and suffixes. Prefix keys lose their last base and keep their order. Crossed-out keys were used at a longer overlap. Each cycle shows its original contigs with the overlapping prefixes and suffixes highlighted. Dashed outlines mark the cut. Each displayed cycle contig copies the case of its span in the masked output. Cycle 1 goes from 4 to 6 to 5 and back to 4. Cutting 5 to 4 gives CTTCGgGCGTtaa. Cycle 2 goes from 8 to 2 to 1 to 3 to 7 and back to 8. Cutting 7 to 8 gives TGCATACaCAGTCACCAATtcCATGatTCTGTttt. The first cut has zero overlap and the second has one base of overlap. Lowercase marks excluded 4-mer starts. k=4 simplitigs 1 ACCAATTCC 2 CAGTCACC 3 CATGATT 4 CTTCG 5 GCGTTAA 6 TCGGGC 7 TCTGTTTT 8 TGCATACACA Overlap 3 Suffixes Prefixes Merge-sort 8 ACA 2 ACC 3 ATT 6 GGC 5 TAA 1 TCC 4 TCG 7 TTT 1 ACC 2 CAG 3 CAT 4 CTT 5 GCG 6 TCG 7 TCT 8 TGC Overlap 2 Suffixes Prefixes Merge-sort 5 AA 8 CA 2 CC 1 CC 4 CG 6 GC 3 TT 7 TT 1 AC 2 CA 3 CA 4 CT 5 GC 6 TC 7 TC 8 TG Overlap 1 Suffixes Prefixes 5 A 8 A 2 C 1 C 6 C 4 G 3 T 7 T 1 A 2 C 3 C 4 C 5 G 6 T 7 T 8 T Overlap 0 Suffixes Prefixes 5 ε 8 ε 2 ε 1 ε 6 ε 4 ε 3 ε 7 ε 1 ε 2 ε 3 ε 4 ε 5 ε 6 ε 7 ε 8 ε Cycle 1 4 3 6 2 5 0 0 · cut 4 Contigs CTTCG TCGgGC GCGTtaa Masked output CTTCGgGCGTtaa lowercase = skipped 4-mer start Cycle 2 8 2 2 3 1 1 3 1 7 1 1 · cut 8 Contigs TGCATACaCA CAGTCACC ACCAATtcC CATGatT TCTGTttt Masked output TGCATACaCAGTCACCAATtcCATGatTCTGTttt

Matchtigs: multi-source bidirectional BFS

Matchtigs search with free connections and weighted unitig traversals DNA labels identify every unitig. A directed edge connects two unitigs with a three-base overlap, at zero cost. Crossing a unitig costs its length minus three. When both ends of a unitig have settled distances, their sum plus the crossing cost gives the bridge cost. The first match consumes its two free ends. The repaired distances yield a second match. k = 4 Each in-between k-mer costs 1 Free suffixes Free prefixes AGGG cost 1 AGGT cost 1 AGGCGG cost 3 ACGG cost 1 ACGA cost 1 GGTGGG cost 3 CGGG cost 1 CGGAC cost 2 CGAC cost 1 AAGG AACG GGGA GACA 1 2 3 4 0 0 0 0 0 0 0 0 0 0 0 0 cost 1 link 0 0 0 0 0 0 0 0 0 0 cost 1 link 0 0 1 0 1 0 1 1 0 1 0 1 0 1 0 0 0 cost 1 link 0 0 1 0 1 cost 2 link 0 1 cost 2 link 1 0 1 0 cost 2 link 1 0 1 0 cost 2 link 0 0 cost 1 link 0 0 1 0 1 cost 2 link 0 1 cost 2 link 1 0 1 0 cost 2 link 1 0 1 0 cost 2 link AAGG AGGG cost 1 GGGA 0 0 0 0 1 0 1 0 1 cost 2 link 1 0 1 0 1 0 1 0 cost 2 link 0 0 0 0 1 0 1 0 1 cost 2 link 1 0 1 0 1 0 1 0 cost 2 link 0 0 0 0 1 0 1 0 1 1 0 1 0 1 0 1 0 AAGG GGGA AACG ACGA cost 1 CGAC cost 1 GACA

Overview

hprcv2-k31.svg

Overview

hprcv2-k63.svg

Bibliography

Břinda, Karel, Michael Baym, and Gregory Kucherov. 2021. “Simplitigs as an Efficient and Scalable Representation of de Bruijn Graphs.” Genome Biology 22 (1). https://doi.org/10.1186/s13059-021-02297-z.
Cracco, Andrea, and Alexandru I. Tomescu. 2023. “Extremely Fast Construction and Querying of Compacted and Colored De Bruijn Graphs with GGCAT.” Genome Research, May. https://doi.org/10.1101/gr.277615.122.
Schmidt, Sebastian, Shahbaz Khan, Jarno N. Alanko, Giulio E. Pibiri, and Alexandru I. Tomescu. 2023. “Matchtigs: Minimum Plain Text Representation of K-Mer Sets.” Genome Biology 24 (1). https://doi.org/10.1186/s13059-023-02968-z.
Sladký, Ondřej, Pavel Veselý, and Karel Břinda. 2023. “Masked Superstrings as a Unified Framework for Textualk-Mer Set Representations,” February. https://doi.org/10.1101/2023.02.01.526717.