k-mer based classification
Kraken 1, Kraken 2, KrakenUniq and Bracken
Four tools, one idea: index every k-mer of every reference genome, map each one to the lowest common ancestor of the genomes that contain it, then classify a read by looking up its k-mers and walking the taxonomy. What separates the versions is how that index is stored, how false positives are controlled, and whether the output is a read count or an abundance.
The algorithm
Kraken 1 → Kraken 2: what actually changed
Kraken 1 (Wood & Salzberg, Genome Biology, 2014) stored every k-mer of every reference genome, exactly, in a sorted structure. It was fast and accurate and it needed an enormous amount of memory. Kraken 2 (Wood, Lu & Langmead, Genome Biology, 2019) changed the storage, and that one change produces every other difference.
| Kraken 1 | Kraken 2 | |
|---|---|---|
| What is stored | every k-mer | minimizers — one representative ℓ-mer per window of k-mers |
| Structure | exact, sorted | compact hash table, storing a truncated hash rather than the full key |
| Consequence | exact lookups | probabilistic: two different keys can collide, producing a small rate of false-positive assignments |
| Accuracy aid | — | spaced seeds in the storage and querying of minimizers |
| Memory / disk | very large | much smaller — the standard database (bacteria, archaea, viruses, human, UniVec_Core) needs roughly 100 GB of disk to build |
| Speed | fast | faster |
Kraken 2's speed and size come from a data structure that can be wrong. The documented database false-positive rate is under 1% of queries, and the stated mitigation is the confidence threshold — which is off by default. So the out-of-the-box configuration is the one with the least protection against exactly the failure mode the design introduced. Setting a confidence threshold is not tuning; it is completing the setup.
KrakenUniq, and the distinct-minimizer idea
KrakenUniq extended Kraken 1 with one additional statistic per taxon: an estimate of the number of distinct k-mers from that taxon seen in the data. That number separates two situations a read count cannot.
Bracken is not a classifier
This is the most common misunderstanding in the family. Bracken (Bayesian Reestimation of Abundance after Classification with KrakEN) does not re-classify anything and does not change any read's taxonomic label. It takes Kraken's output and redistributes the counts.
- The problem it solves Kraken assigns a read to the LCA of everything its k-mers match. For genomes that share a lot of sequence with close relatives, that means most reads pile up at the genus or family node — so the species rows are empty even though the species is abundant.
- What it does Reads sitting above the species level are pushed down to species; reads sitting at strain level are pulled up to their parent species. The probabilities come from the Kraken database itself: how much of each genome is identical to each other genome.
- Which is why it is read-length specific
bracken-buildmust be run for the k-mer length used to build the Kraken database and for the read length you will analyse. A distribution file built for 100 bp reads is the wrong file for 150 bp reads. - And why it cannot rescue a bad classification Bracken redistributes whatever Kraken gave it. If Kraken produced spurious taxa — no confidence threshold, a contaminated database, hash collisions — Bracken will faithfully redistribute reads into them, and give the artefact a confident-looking abundance. Filter first, then Bracken.
The database is the method
Ranked roughly by how much each decision moves the answer, which is not the order most people spend their attention in:
| Decision | Effect | Default |
|---|---|---|
| Which reference database | Largest. Standard (bacteria, archaea, viral, human, UniVec_Core) versus a PlusPF-style build with protozoa and fungi versus a full nt build are different experiments | whatever you downloaded |
| Confidence threshold | Large. Trades recall for precision; raising it walks labels up the tree rather than discarding them | 0.0 — none |
| Distinct-minimizer filtering | Moderate and cheap. Removes the pile-on-one-region artefacts | off |
| Minimum hit groups | Small but free | 2 |
| Host and vector removal | Large in host-associated or low-biomass samples | partly handled by including human and UniVec_Core in the standard DB |
| Bracken read length | Moderate; wrong file means wrong redistribution | must match your reads |
Pre-built indexes are published and versioned, which is the reproducible way to do this: cite the index build you used, by date, alongside the tool version. "Kraken 2 standard database" without a build date is not reproducible — the standard database is a moving target, because RefSeq is.