Calling Antibiotic Resistance Directly from Raw Nanopore Current

When a patient has a carbapenem-resistant infection, the standard laboratory answer arrives 48 to 72 hours after sampling. Until then, clinicians treat with broad-spectrum antibiotics (Affordable and real-time antimicrobial resistance prediction from multimodal electronic health records uses this delay to motivate its EHR-based predictor). Nanopore sequencers could close much of that gap. They read DNA as a noisy electrical current while the molecule is still passing through the pore. The usual pipeline, however, first converts the current into letters ("base-calling"), which is error-prone and compute-heavy, and only then searches for resistance genes. We propose to skip that step. Each reference resistance sequence is converted into the current it should produce, and that expected trace is searched for directly in the raw signal with dynamic time warping (DTW). DTW is an alignment method that lets one sequence locally stretch or compress against another, so a match is still found when the DNA moved through the pore at an uneven speed. The output is a running, per-sample answer to three questions: is a resistance gene present, which close variant is it, and is it sitting on a mobile element that can spread.

The new part is not raw-signal search itself. That was shown for general genomic targets by Novel algorithms for efficient subsequence searching and mapping in nanopore raw signals towards targeted sequencing. The new part is turning it into a resistance caller that can tell near-identical alleles apart and can place a gene on its mobile carrier, two things single-query distance thresholds cannot do. Concretely, we score each read against competing allele-specific and junction-specific reference traces. We accumulate that evidence across reads as a sequential test, so a call can be issued, with a stated error rate, after the fewest reads possible.

Core Claim

Resistance calling has a contrastive structure that generic subsequence search ignores. The clinically decisive differences are often small: carbapenemase variants within a family, or the 23S rRNA point mutations G2576T and C2104T that confer linezolid resistance (Jiachang Cai et al.). The decisive context is often a boundary rather than a gene, such as the IS26 composite transposon carrying blaKPC-2 on a conjugative plasmid (Lingyi Zeng et al.). We claim that comparing a read's warping cost against two or more competing references yields a reliable signal even when the differing region is far shorter than the roughly 128 bp minimum that DSDTWnano needs for detection. The competing references share long flanking context and differ only at the variant or junction. Formally, for a read $r$ and two reference current traces $q_A$ and $q_B$ built from the same flanking window, let $D_\gamma(r, q)$ be the soft-DTW cost of the best-matching subsequence. Soft-DTW is the smoothed, differentiable version of DTW from Soft-DTW: a Differentiable Loss Function for Time-Series, with smoothing scale $\gamma$. The per-read evidence is

$$s(r) = D_\gamma(r, q_B) - D_\gamma(r, q_A),$$

and over reads $r_1, \dots, r_n$ that hit the window, the sample-level statistic is $\Lambda_n = \sum_{i=1}^n \log \frac{p(s(r_i)\mid A)}{p(s(r_i)\mid B)}$. The two densities $p(\cdot \mid A)$ and $p(\cdot \mid B)$ are calibrated on reads of known genotype. A call is made once $\Lambda_n$ crosses thresholds set for target false-call rates, following the logic of a sequential probability ratio test. This turns the 128 bp limitation flagged in the file's tension section into a design rule instead of a barrier: the variant is not the query; the flank is.

Research Program

The method borrows its building blocks from the nanopore DTW line of work. An accurate and rapid continuous wavelet dynamic time warping algorithm for unbalanced global mapping in nanopore sequencing supplies the speed. Its cwDTW compresses the current with a multi-scale wavelet transform, keeps peaks and troughs, and refines the alignment from coarse to fine. It reports exact optimal paths on 86.4% of reads and runs about 3000 times faster than plain DTW and 440 times faster than FastDTW. Novel algorithms for efficient subsequence searching and mapping in nanopore raw signals towards targeted sequencing supplies the reference-to-signal subsequence search and its linearity filter. That paper also supplies the constraint we design around, the ~128 bp query floor. Neither paper touched resistance genes, alleles, or mobile elements.

We will build three components on top of these. The first is a resistance panel compiled into expected-current traces using a k-mer pore model. It covers carbapenemases (blaKPC, blaVIM and other metallo-β-lactamases), mcr colistin genes including mcr-9, cfr, and 23S rRNA windows around the linezolid mutation sites. For each family, the panel holds allele-specific traces that share at least ~150 bp of flank, so that every contrast in the equation above sits inside a detectable window. The second is a set of junction traces that span gene-to-IS26 and gene-to-plasmid-backbone boundaries, scored against "gene with chromosomal flank" alternatives. These answer whether a gene is mobilizable, which matters because co-located mechanisms such as mcr-9 together with metallo-β-lactamases (Kewang Hu et al., Jie Li) travel as one unit. The third is the sequential decision layer. It calibrates score densities per contrast and reports a call, its error bound, and the number of reads and minutes it took.

Multi-copy targets such as 23S rRNA need special handling. A single isolate may carry the mutation in only some copies, so the decision layer for those windows estimates a mutant fraction from the distribution of $s(r)$ rather than issuing a binary call. That fraction is then reported against measured MIC (minimum inhibitory concentration, the lowest drug dose that stops visible growth).

Data has to be generated, because the file lists no resistance-annotated raw nanopore benchmark; no reported result found on Lacuna for raw-signal resistance gene detection. We will use two sources. The first is simulated current from PATRIC genomes with known resistance phenotypes (the same resource behind the k-mer results in Machine Learning for Antimicrobial Resistance), at controlled noise levels. The second is real nanopore runs of clinical isolates of carbapenem-resistant Klebsiella pneumoniae, Acinetobacter baumannii, and linezolid-resistant Gram-positives. Ground truth for these isolates comes from hybrid assemblies plus broth microdilution MICs, as in Xiaochun Fu et al.. The public E. coli and Lambda datasets from the DSDTWnano paper serve as sanity checks that our reimplementation reproduces its reported behavior.

Baselines

The naive reference point is the clinical status quo: phenotypic MIC by broth microdilution, at 48 to 72 hours. Every method will be reported as time-to-correct-call against this anchor, not only as accuracy.

The strongest existing raw-signal method is DSDTWnano/cwSDTWnano used exactly as published. Each panel allele is a separate query, and a gene is called when the subsequence DTW distance drops below a threshold. On its own targets it reports a Matthews correlation coefficient (MCC) of 0.947 at 80% read accuracy, against 0.362 for Minimap2 and 0.685 for BLAST. It also reports a 90% SNP detection rate at 20x coverage against under 70% for Nanopolish (Novel algorithms for efficient subsequence searching and mapping in nanopore raw signals towards targeted sequencing). It is the strongest competitor because it already solves raw-signal presence detection. Any gain we claim has to come from the contrastive scoring and the sequential layer, not from raw-signal search per se. We run it on identical reads, the same pore model and panel, the same CPU budget, and with its threshold tuned on the same calibration split we use for our densities. Beating it means higher MCC for allele-level and junction-level calls at matched coverage, and reaching a fixed error rate with fewer reads. Presence-only detection, where we expect parity, will be reported but not counted as a win.

The strongest base-called competitor is a current production base-caller followed by Minimap2 and BLAST against the same panel, run on the same reads. It gets GPU base-calling time charged to its latency. The file's Minimap2 number comes from 80%-accuracy reads, and modern base-callers are more accurate, so we will rerun it rather than quote it.

For the phenotype question we also include k-mer Random Forests trained on assembled genomes, which reach up to 92% accuracy on PATRIC (Machine Learning for Antimicrobial Resistance). This baseline is evaluated on susceptibility agreement and requires a completed assembly.

Two ablations isolate the key ingredient. The first replaces the contrast score $s(r)$ with each allele's raw distance used independently. The second replaces the sequential test with a fixed read count. A third, speed-only ablation swaps cwDTW for FastDTW, given the >200% relative distance errors cwDTW's authors attribute to FastDTW on unbalanced signals.

Why not just…?

Why not just base-call and align to a resistance database? This is the real threat. If a modern base-caller makes reads accurate enough, text alignment may tell alleles apart as well as our contrast score does. The evidence that it does not, MCC 0.362 for Minimap2, comes from 80%-accuracy reads (Novel algorithms for efficient subsequence searching and mapping in nanopore raw signals towards targeted sequencing) and may be stale. Our experiment reruns this pipeline at current accuracy. If it matches us on allele and junction calls, the remaining case for raw-signal calling rests on latency and compute: no GPU, a decision made mid-run, and CPU-only operation at the bedside or in a wastewater lab. We will report that case honestly as a narrower claim.

Why not just run DSDTWnano with every allele as its own query? Within a family, alleles differ by a few bases inside long shared sequence. Independent thresholds will therefore fire for all of them, and point mutations fall below the 128 bp floor. The first ablation tests exactly this. If independent distances already separate the alleles, the contrastive layer adds nothing, and we will drop it in favor of the sequential stopping rule alone.

Why not just predict resistance from genomes with k-mer classifiers? They work well, reaching 80–92% accuracy (Machine Learning for Antimicrobial Resistance), but they need assembled genomes, which costs hours to days and erodes the speed advantage. They also cannot say whether a gene sits on a transferable element, which is the information infection control needs for plasmid outbreaks such as the one reported by Lingyi Zeng et al.. We compare the two approaches at matched wall-clock time.

Why not just predict resistance from the patient record instead? EHR models give early warnings, but their precision is low. The best multimodal model reaches AUROC 0.7565 yet AUPR only 0.1825 for gentamicin resistance (Affordable and real-time antimicrobial resistance prediction from multimodal electronic health records), and it never identifies the mechanism. We see these models as complementary priors rather than competitors, and we do not claim to beat them on their own task.

Proposed Experiments

The first decisive check is on simulated reads. We sweep read accuracy and coverage and measure allele-level MCC for carbapenemase families and the 23S windows. The test is whether contrast scoring holds above 0.9 MCC at coverages where independent-query DSDTWnano collapses. A failure here at realistic noise ends the allele-discrimination claim.

The second check uses the clinical isolates. We measure time and reads to a correct call for blaKPC-2 presence, allele identity, and IS26/plasmid junction, against the base-called pipeline at equal hardware cost. For the linezolid isolates we test whether the estimated 23S mutant fraction tracks MIC. Success means calls within the first minutes of a run and at least parity with base-calling on accuracy.

The third check is a wastewater-style mixture: isolate DNA is spiked into background DNA at decreasing fractions, mimicking the hospital-to-wastewater VIM cycling described by Philipp Köhler et al.. It measures false-call rates when most reads are off-target. That rate, more than accuracy on pure isolates, decides whether the sequential thresholds are trustworthy enough for surveillance use.