506 A better letter-free code, found by searching all rules

The layers above need a code: a rule that turns the current of one record into a sequence of symbols, so that the same stretch of molecule read twice gives the same symbols. No alphabet is given in advance; the number of symbols is a choice, and four is never used. This subsection asks which rule makes records agree best with one another, measures it by a single criterion that uses no letters, no pairing, no reference and no comparison of records with each other, and keeps the rule only if it also wins on records never used to choose it.

Records. All 17,327 records of at least 20,000 samples from the first five files of the E. coli ER2925 deposit (Zenodo 7995806, R9.4.1, SQK-LSK109, MinION, 4 kHz) are used, as events (two-sided \(t\)-statistic, window 4 samples, threshold 5; event mean; per-record median/MAD scaling).

Criterion. A fixed set of the longest records (their first 8,000 and last 2,000 events removed) is written in the rule’s symbols and joined into one sequence \(\Omega \). Every other record contributes one piece: the symbols of its central 5,500 events. A piece is placed on \(\Omega \) when enough seeds of \(k\) symbols (with \(k\log _2(A-1)\approx 26\) bits, since consecutive symbols differ) fall on one diagonal. The number of seeds required is not chosen by hand: it is the smallest value at which time-reversed pieces are placed less than 5% of the time. The score is

\[ \text {excess} = \text {share of pieces placed} - \text {share of time-reversed pieces placed}. \]
Time reversal keeps the symbols and their frequencies but destroys their order, so the excess counts pieces that sit on \(\Omega \) because of the order of their symbols. A second control, forward order-3 Markov stand-ins generated from the records’ own symbols, keeps the short-range order as well; on an \(\Omega \) of \(10^6\) symbols it was placed 0.000 of the time against 0.159 for the records, so the excess does not come from short-range habits of the code. Pieces taken from the first part of each record were excluded, because the stretch every molecule shares on entering the pore drew all records onto one another (placement 0.198 at the start of records against 0.052 at their centre on the same \(\Omega \)).

Search. Records outside \(\Omega \) with at least 7,000 events were shuffled and split into two halves of 2,000 records. Sixty rules were scored on the first half; the five best and the rule used so far were then scored on the second half, which played no part in choosing.

Setting Values
Number of symbols \(A\) 5, 6, 7, 9, 11, 13
Margin to cross a boundary (in units of the scaled current) 0, 0.15, 0.30, 0.50, 0.80
Value coded event value, or median of three neighbouring events
Boundaries equal-frequency quantiles of the event values
Repeats consecutive equal symbols merged
Table 440: The 60 rules searched. Each rule is fixed before it is scored.

Rule Excess Placed Time- Excess vs.
(choosing) reversed (final) previous
Previous: \(A=6\), 0.30, value – 0.057 0.017 0.040 –
\(A=9\), 0.15, value 0.173 0.232 0.045 0.187 \(\times 4.7\)
\(A=7\), 0.15, value 0.115 0.168 0.041 0.127 \(\times 3.2\)
\(A=9\), 0.30, value 0.114 0.151 0.038 0.113 \(\times 2.8\)
\(A=5\), 0.80, median of 3 0.101 0.124 0.025 0.100 \(\times 2.5\)
\(A=7\), 0.50, value 0.107 0.138 0.040 0.098 \(\times 2.5\)
Table 441: The five rules with the largest excess on the choosing half, scored again on 2,000 records that were not used to choose them. Rules are written as (\(A\), margin, value coded).

All five chosen rules beat the previous one on the final half, and their scores on the final half match their scores on the choosing half to within 0.014, so the ranking is not an artefact of choosing. The best rule uses nine symbols and a margin of 0.15: it places 23.2% of unseen records’ pieces on \(\Omega \) while time-reversed pieces stay at 4.5%, an excess of 0.187, 4.7 times the previous rule. The direction across the top rules is consistent: slightly more symbols than six, and a smaller margin.

Polishing. With the best rule, \(\Omega \) (\(1{,}227{,}592\) symbols) was rewritten five times by the majority symbol of the pieces placed on each position, the records that built \(\Omega \) voting no part. Pieces placed rose from 0.190 to 0.214 (time-reversed 0.049 to 0.039), median depth was 10 to 11, and the share of positions left unchanged by a round rose to 0.971, so \(\Omega \) approached a fixed point. On the final half, however, the excess was 0.170 after polishing against 0.187 before; with 2,000 records the difference is about two standard errors. At this depth, with the majority symbol holding a median of 0.62 of the votes, polishing neither helped nor harmed placement of unseen records.

Learned codes. Before this search, codes produced by neural networks were scored against the same criterion and lost to the simple rule.

Code Excess
Quantile rule, \(A=6\) (same records and unpolished \(\Omega \) of \(10^6\) symbols) 0.123
Clusters of pretrained features (\(K=50\)), per 2 ms bin 0.009
Clusters of pretrained features (\(K=50\)), averaged over 5 bins 0.035
Clusters of pretrained features (\(K=50\)), averaged over 10 bins 0.002
Masked prediction of rule symbols, then clusters (\(K=50\), 5 bins) 0.008
Table 442: Codes from a network pretrained on raw current by masked reconstruction (four sources: E. coli, human GM24385, human NA12878 bulk blockades, Hct116 direct RNA), compared with the quantile rule.

Networks trained with CTC to emit the symbols of a polished \(\Omega \), including the open Bonito trainer with its alphabet replaced by six symbols of our own, did not, when each reader was given its own seed threshold, place held-out records better than time-reversed ones. With the present amount of data, a fixed quantile rule with nine symbols and a small margin is the best letter-free code found, and it is found by search rather than by learning.

506.1 The same search on human DNA, bulk blockades and RNA

The search of Section 506 was repeated on three further sets of raw current with the same 60 rules, the same criterion and the same split into a choosing half and a final half. For each set, \(\Omega \) is made from its own longest records, with the start and end of each record removed in proportion to its length (at most 20% and 5% of its events, and never more than the 8,000 and 2,000 events used for E. coli). Pieces are the central 5,500 events of every other record, or its central half when the record is shorter. The bulk set was subsampled to 20,000 records.

Set Source Instrument Records \(\Omega \) from Pieces from records of
E. coli gDNA Zenodo 7995806 MinION, R9.4.1 17,327 longest records \(\geq 7{,}000\) events
Human gDNA GM24385, PAF27096 PromethION, R9.4.1 15,780 23 longest \(\geq 4{,}504\) events
Human gDNA, bulk NA12878, FAF14035 MinION, our blockades 20,000 of 88,001 13 longest \(\geq 5{,}651\) events
Human RNA Hct116, SG-NEx direct RNA, R9.4.1 20,000 759 longest \(\geq 1{,}000\) events
Table 443: Sets searched. Each set uses its own \(\Omega \), its own pieces and its own seed thresholds, chosen by the same rule (time-reversed pieces placed less than 5% of the time).

Set Previous rule Best rule on the final half Excess, choosing Excess, final Ratio
E. coli gDNA 0.040 \(A=9\), margin 0.15, value 0.173 0.187 4.7
Human gDNA 0.026 \(A=5\), margin 0.80, median of 3 0.040 0.063 2.4
Human gDNA, bulk 0.003 \(A=6\), margin 0.50, median of 3 0.017 0.029 –
Human RNA 0.011 \(A=5\), margin 0.80, value 0.024 0.020 1.8
Table 444: Excess of the previous rule (\(A=6\), margin 0.30, event value) and of the best rule on the final half, for each set. The ratio for the bulk set is not given because the previous rule’s excess is indistinguishable from zero.

Rule (chosen on the choosing half) Human gDNA Human gDNA, bulk Human RNA
Previous rule: \(A=6\), margin 0.30, value 0.026 0.003 0.011
\(A=5\), margin 0.80, median of 3 0.063 0.015 –
\(A=5\), margin 0.80, value 0.041 – 0.020
\(A=5\), margin 0.50, median of 3 0.036 0.015 –
\(A=6\), margin 0.50, median of 3 – 0.029 –
\(A=7\), margin 0.30, value – – 0.019
\(A=9\), margin 0.50, value 0.041 – 0.002
Table 445: Final-half excess of the five rules chosen on each set (a dash marks a rule not among that set’s five). With about 2,000 pieces per half, the standard error of an excess is close to 0.006.

On every set, a rule chosen on one half places the other half’s pieces on \(\Omega \) more often, relative to time-reversed pieces, than the rule used before. The gain is large for E. coli (0.040 to 0.187), clear for human gDNA (0.026 to 0.063) and for the bulk blockades (0.003 to 0.029), and at the edge of the standard error for RNA (0.011 to 0.020). Several rules flagged as better in Table 445 differ from the previous rule by less than one standard error and are not counted as gains.

The size of the excess follows how often different records pass over the same stretch. The bacterial genome is small and was read about 45 times, so many pieces fall on \(\Omega \). The human nuclear genome is about 650 times larger and was read well under once, so pieces fall on \(\Omega \) only where the same stretch exists in many copies, such as the mitochondrial genome and repeated elements; the excess is correspondingly small but not zero. The RNA records are short, so their pieces carry fewer symbols and are placed less reliably.

The best rule differs between sets. On the bacterial MinION run, a small margin (0.15) wins: the current is clean enough that small changes are worth a new symbol. On the human PromethION run, the bulk blockades and the RNA run, larger margins (0.50 to 0.80) win, and on both human sets the median of three neighbouring events, which suppresses single outlying events, is among the best. A rule that changes symbol only on a clear change in current is better where the current is noisier. None of these rules uses letters, pairing, a reference or comparison of records with each other; each is fixed before it is scored, and each set is scored on records that were not used to choose its rule.

506.2 One rule for all sets, and polishing with each set’s own rule

Two further questions were asked of the four sets of Section 506.1. First, whether a single rule serves all of them: for each of the 60 rules, its rank by excess on the choosing half was taken in each set, and the rule with the best mean rank over the four sets was scored on each set’s final half. Second, whether \(\Omega \) built with each set’s own best rule improves when rewritten by majority: three rounds of polishing, the records that built \(\Omega \) and the final half voting no part, each round scored on the final half.

Set Previous rule Own best rule One rule for all
\(A=6\), margin 0.30, value \(A=5\), margin 0.50, median of 3
E. coli gDNA 0.040 0.187 (\(A=9\), 0.15, value) 0.023
Human gDNA 0.026 0.063 (\(A=5\), 0.80, median of 3) 0.036
Human gDNA, bulk 0.003 0.029 (\(A=6\), 0.50, median of 3) 0.015
Human RNA 0.011 0.020 (\(A=5\), 0.80, value) 0.013
Table 446: Final-half excess of the previous rule, of each set’s own best rule, and of the rule with the best mean rank over the four sets (mean rank 6.2 of 60).

The rule with the best mean rank is better than the previous rule on human gDNA and on the bulk blockades, equal to it on RNA within the standard error, and worse than it on E. coli (0.023 against 0.040). No single rule among the 60 is the best on all four sets, and each set’s own rule beats the shared one on every set. What carries over between sets is therefore not one rule but the procedure that finds a rule: fix the rule before scoring, choose on half the records, and keep it only if it wins on the other half.

Set Own rule, unpolished Round 1 Round 2 Round 3 Depth after round 3
E. coli gDNA 0.187 0.138 0.152 0.158 10
Human gDNA 0.063 0.099 0.040 0.036 3
Human gDNA, bulk 0.029 0.013 0.007 0.008 2
Table 447: Final-half excess when \(\Omega \), built with each set’s own rule, is rewritten by the majority symbol of the pieces placed on it. Depth is the median number of pieces covering a position. Rounds here used at most 40,000 pieces each; the five-round polishing of Section 506, with all pieces, ended at 0.170 for E. coli. The RNA set is not shown: its records were shorter than the piece length used for polishing, so no piece was formed.

Polishing did not raise the final-half excess above that of the unpolished \(\Omega \) on any set. On E. coli, where depth reaches about ten, the excess recovers over three rounds toward its unpolished value but stays below it. On human gDNA the first round raised it to 0.099 and the second fell back to 0.040; at a depth of three a majority is decided by one or two pieces, and \(\Omega \) moves with them. On the bulk blockades, fewer than 6% of positions were covered by three or more pieces, too few for a majority to form. With the present depth, the order of symbols that a fixed rule reads from the current is already the best \(\Omega \) these sets support; rewriting it by majority needs many more passes over the same stretch than the human sets contain.

pict

Figure 469: (a) Excess on the choosing half for all 60 rules on the four sets; the dashed line marks the rule with the best mean rank. (b) Final-half excess of the previous rule, each set’s own best rule and the shared rule. (c) Final-half excess over rounds of polishing with each set’s own rule; the flat RNA curve reflects that no piece was formed for that set (see Table 447).