Key findings
- Even when every fragment is drawn from its own genome's 5-mer composition, a t-SNE map places it with its genus 99% of the time at 4 kb, but only 66% of the time at 1 kb.
- Genome-level placement needs more sequence: against 10 kb windows, the ideal map loses about 1 point at 8 kb, 7–8 points at 4 kb, 20 at 2 kb and 47–48 at 1 kb.
- In real 10 kb windows, 59% of the spread around a genome's mean signature is sampling noise; local GC, codon and amino-acid composition explain half of the rest, and replication-strand skew explains 0.15%.
- The windows that every map misplaces are pulled away by the proteins they encode: redrawing their amino acids from the genome's average raises their genus accuracy from 62% to 88%.
- A linear correction from gene annotations alone raises genome accuracy by 3.3 points; with each genome's average annotation as well, by 8.8 points.
Introduction
Assembled contigs and long reads can be grouped by genome without a reference because each genome has a fairly constant short-word composition, its genomic signature . We use this for maps of every read or contig: count canonical 5-mers in each sequence, take square roots, reduce to 128 principal components, and embed with t-SNE using fastsne, our GPU and CPU implementation. Fragments from one genome should then land together.
To measure how often they do, we cut all 199,923 species-representative genomes of GTDB release 232 into 49.7 million windows of 10 kb and asked, for each window, whether most of its 15 nearest neighbours come from its own genus. In the 5-mer space itself 91.0% do; in a 2D map 86.3%, and in a 3D map 87.4%. A small set of windows is misplaced by every map we made, and these are already misplaced before any embedding: only 19% of them have a majority of own-genus neighbours among the raw 5-mer profiles.
That leaves two questions, which this report takes in turn. First, how much is lost simply because a fragment is short, even if genomes were perfectly uniform? This sets what to expect from shorter contigs and reads. Second, in real genomes, what biology moves a window away from its genome's signature (GC content, codon usage, replication-strand skew, the genes it carries), and could a correction based on gene annotations move it back?
Window length in the ideal case
We took a random 10% of the GTDB genomes (20,084 genomes) and replaced every window with one drawn from its own genome's pooled 5-mer frequencies. In the sampling only version each window is a multinomial draw, so the only difference from its genome is counting noise. In the spread version each window's frequencies first scatter around the genome's as widely as that genome's real windows do (minus its 10% most atypical windows), in random directions, and are then sampled. At 10 kb these two bracket what is achievable: real windows of the same genomes reach 90.2% genus and 67.9% genome accuracy in a 2D map, the spread version 99.7% and 91.0%, sampling only 99.9% and 93.9%. Removing each genome's 10% most atypical windows alone takes real windows to 94.0% and 72.4%.
We then redrew the same genomes at 1, 2, 4, 8, 16 and 32 kb, with as many windows per genome as it has real 10 kb windows, made a 2D map of each, and scored every space with the same 15-neighbour rule ().
Genus placement is robust: in the 2D map the ideal case loses 0.1–0.2 points at 8 kb and 1.0–1.3 at 4 kb against 10 kb, then 7–9 points at 2 kb and 34–35 at 1 kb. Genome placement falls sooner: about 1 point at 8 kb, 7–8 at 4 kb, 20 at 2 kb and 47–48 at 1 kb. Above 10 kb, the sampling-only windows keep improving (93.9% genome accuracy at 10 kb, 98.4% at 32 kb) while the spread version levels off (91.0% to 94.5% in the map, and 82% from 8 to 32 kb among the raw profiles), because its genome-wide scatter does not shrink with more sequence.
Short windows favour fewer dimensions. At 1 kb, 32 principal components beat 128 by 9 points of genus accuracy (83.6% against 74.1%, sampling only), and square-root 4-mers beat 5-mers (73.6% against 55.7%), because with about 1,000 counts spread over 512 features most of each profile is noise. For reads or contigs of a few kb, a smaller PCA or shorter k-mers is worth trying.
Where the spread around a genome comes from
For the biology we chose a smaller sample that could be annotated in full: 2,643 genomes from 540 genera, 150 families and 23 phyla, at least 90% complete and at most 5% contaminated, with gene calls and COG annotations from GlobDB. 1,272 of them are complete in a single contig. They give 963,843 windows of 10 kb. For each window we recorded its GC content, coding share and strand, codon adaptation index (CAI) against the genome's ribosomal-protein genes, GC at third codon positions (GC3), amino-acid composition, COG functional categories, and, for complete genomes, its share of genes on the leading strand and its replichore. Neighbours are searched within this sample, so accuracy is higher than in the full benchmark: genus 95.2%, genome 70.7% among the first 128 principal components. Compare versions, not absolute values.
The variance of windows around their genome's mean profile (square-root 5-mer frequencies) is 0.0216, of which 59.0% is the sampling noise expected of any 10 kb window. We fitted the remainder linearly on each group of annotation features, within genomes ().
GC content, codon bias and amino-acid composition each explain about 30% on their own, but mostly the same 30%: local GC drives both GC3 and which amino acids are used. Only amino-acid composition carries a sizeable share of its own (11.4%). Gene layout and COG functional categories explain about 4% each.
GC skew and replication. The leading and lagging strands of bacterial chromosomes differ in composition , and canonical k-mers cannot see this because they merge each word with its reverse complement. In complete genomes, the leading-strand share and replichore explain 0.15% of the within-genome variance (0.05% beyond the other features). Counting all 1,024 oriented 5-mers, with each window oriented by its genes' majority strand or by the leading strand, made placement worse, not better: genome accuracy 77.9% and 77.8% against 80.5% for canonical 5-mers on the same complete genomes. At 10 kb the skew is real but small next to sampling noise, and doubling the features adds more noise than signal.
Highly expressed genes. CAI on its own explains 4.4% of the within-genome variance, but only 1.0 point beyond GC and amino-acid composition. The windows far from their genome are not the highly expressed ones (): distance rises from 0.131 for windows of typical CAI to 0.202 for those 4 standard deviations above their genome's mean, but to 0.292 for those 4 below, the windows whose codon usage looks foreign. Distance rises with unusual GC in both directions (0.311 at 4 below, 0.290 at 4 above).
Rebuilding genomes from their annotations
To see which layer of a genome's sequence makes windows stray, we rebuilt every genome three ways from its own annotation, each time keeping the gene order and lengths. Synonymous: every codon replaced by one drawn from the genome's overall usage for that amino acid. + intergenic: in addition, intergenic DNA redrawn from the genome's order-4 Markov chain. + amino acids: in addition, every amino acid redrawn from the genome's amino-acid frequencies. We grouped query windows by how many of the benchmark's nine maps had misplaced them ().
Synonymous recoding made windows harder to place (genome accuracy 63.8% against 70.7%). Drawing each codon independently keeps codon usage but destroys codon-pair and codon-boundary context, so that context is part of the genome's 5-mer signature. Redrawing intergenic DNA recovered a little (66.0%). Redrawing the amino acids recovered the rest and more (72.7%), and changed the strays most: among windows all nine maps misplaced, genus accuracy rose from 62.5% for real windows to 87.7%, and genome accuracy from 43.7% to 67.1%. What pulls those windows away from their genome is the protein content of the genes they carry, not noise and not codon usage.
A corrected signature from gene annotations
If annotations predict how a window deviates, subtracting the prediction should bring it back. We fitted a linear map from a window's annotation features (gene layout, CAI, GC3, amino-acid composition, optionally COG categories and GC) to its deviation from its genome's mean profile, on half the genomes, and applied it to windows of the other half before searching neighbours. A blind correction uses only the window's own annotation, as a contig with genes called on it would have. An oracle correction also knows its genome's average annotation, which a real pipeline would have to estimate from a first-pass bin ().
The blind correction raised genus accuracy from 95.1% to 96.3% and genome accuracy from 70.4% to 73.7%; among the windows all nine maps misplaced, genus accuracy rose from 60.4% to 70.5%. Adding COG categories or GC changed nothing. The oracle raised genus accuracy to 97.8% and genome accuracy to 79.3% (strays 81.1%), the ceiling for a bin-then-correct scheme with these features.
Discussion
For maps of contigs or reads, length matters mostly below 4 kb at genus level and below 8 kb at genome level, and these are best-case numbers: at 10 kb, real windows of the same genomes are 10 points lower than the ideal case at genus level and 23–26 points lower at genome level in the 2D map. Above 10 kb, the ceiling for telling genomes apart is set by each genome's own heterogeneity rather than by sequence length.
That heterogeneity is mostly what the genes are. The windows that every map misplaces carry proteins whose amino-acid composition differs from their genome's, often with foreign-looking codon usage, consistent with recently acquired genes. Replication-strand skew and the codon bias of highly expressed genes are real but minor at this scale. An annotation-based correction recovers a useful part of the gap, and most of what it can recover needs a genome-level estimate of annotation, which suggests an iterative scheme: map, bin, estimate each bin's average annotation, correct, and map again. We have not tested that.
Limitations. The simulations treat each genome as one composition with symmetric scatter; real heterogeneity is structured (islands, plasmids, phage), which is why real windows do worse. The length series uses a fixed k-mer total per window, while the 10 kb reference keeps each real window's total. The biology sample is small next to the benchmark (2,643 against 199,923 genomes), so its accuracies are higher; differences between versions are the result. The variance decomposition is linear, and the corrections are linear maps; a non-linear model might recover more. Benchmark strays were defined on the full benchmark and carried over to these windows by identifier.
Methods
Benchmark. GTDB release 232 species representatives cut into non-overlapping 10 kb windows (49,684,458
windows, 199,923 genomes, 37,503 genera), counted as 512 canonical 5-mers, square-root transformed, reduced to
128 principal components and embedded with fastsne (2D maps with --h 0.25 and 10,000 iterations; 3D maps with
--dims 3) on the Fir cluster (Digital Research Alliance of Canada). A window is placed correctly when most of its
15 nearest neighbours share its genus (or genome), ties counted for it. Exact neighbours were computed for
10,000 random query windows.
Simulations. simgen.py draws 10% of genomes (seed 3) and writes real windows, trimmed windows
(without each genome's 10% farthest from its mean in square-root frequency space), multinomial windows from the
genome's pooled 5-mer frequencies, and Dirichlet-multinomial windows whose concentration is fitted per genome so
that the variance of trimmed real windows is matched. simlen.py redraws the same genomes at L kb with
1000L − 4 counts per window, keeping the 10 kb concentration. Maps and scores as for the benchmark.
Biology. Genomes from GTDB release 232 that are also in GlobDB release 226 with completeness ≥ 90%,
contamination ≤ 5% and ≥ 100 windows, from genera with ≥ 4 such genomes including a complete one, in families
with ≥ 3 such genera; up to 4 genera per family and 5 genomes per genus (complete genomes first; seed 11).
bio_windows.py computes per-window features from GlobDB gene and COG annotations (COG 2020), CAI with
weights from genes of ribosomal-protein COGs, origin and terminus from the minimum and maximum of cumulative GC
skew, and the rebuilt and oriented counts. bio_eval.py runs exact 15-neighbour searches for 30,000
query windows after square-root transform and 128-component PCA; decomposes within-genome variance with
expected sampling noise Σ(1 − pi)/4T per window; and fits the corrections on genomes with even
CRC32 of their accession, testing on the rest. cai_follow.py separates CAI from GC and computes the
distance profiles. Python 3.12 (simulations, on Fir) and 3.13 (biology) with NumPy and pandas. Code and derived data:
reports-kmer-map-limits.