667 Sequencing

A genome is reported as a string over \(\{A,C,G,T\}\). What the instrument records is an ionic current trace or a fluorescence intensity series. This subsection traces what lies between.

667.0.1 The base call

Modern basecallers are neural networks. bonito and dorado decode the raw squiggle with CTC beam search; the decode width is a parameter, taking values \(\{1, 5, 32, 100\}\) in bonito and \(\{0, 32, 100\}\) in dorado. Before decoding the signal is rescaled, with normalisation parameters specified per chemistry version — reader.py carries a block headed Normalisation parameters for kit 14 DNA.

The network weights are trained on reads aligned to a reference. The label \(A\) at a given position is therefore the output of a model optimised to agree with a reference sequence, and that reference was assembled from the output of earlier basecallers.

667.0.2 The quality score

The Phred score is defined as

\[ Q = -10 \log _{10} P(\text {error}). \]
\(P\) is not measured. In gatk this conversion appears in \(132\) places, in deepvariant \(17\), in dorado \(6\). The probability supplied to it is a model output: a softmax posterior for nanopore, an HMM posterior for bcftools (phred_score(1.0 - HMM_PPROB(...))), a genotype likelihood for deepvariant (gq = min(floor(-10 * log10(1 - norm[1])), max_gq)).

\(Q40\) therefore does not assert that the base is wrong once in ten thousand times. It asserts that a particular model assigned that number.

667.0.3 Base quality score recalibration

gatk recalibrates the reported qualities against an empirical rate. The documentation of BaseRecalibrator states the assumption directly:

It does a by-locus traversal operating only at sites that are not in the known-sites resource. […] We assume that all reference mismatches we see are therefore errors and indicative of poor base quality.

Every position where the read disagrees with the reference, and which is not already listed in a variant database, is counted as a sequencing error. The empirical quality is the rate of such disagreements.

Two consequences follow. A true variant absent from the database is scored as an error and lowers the quality of the reads carrying it. And the recalibration requires the database: RUN_WITHOUT_DBSNP = false is the default, and the supplied resources are dbsnp_132, dbsnp_138 — catalogues assembled from earlier sequencing.

The context over which the correction is binned is fixed at MISMATCHES_CONTEXT_SIZE = 2.

667.0.4 Variant filtering

gatk’s VariantRecalibrator fits a Gaussian mixture to variants labelled by external resources, each entering with a hand-assigned prior:

–resource:hapmap,known=false,training=true,truth=true,prior=15.0
–resource:omni,known=false,training=true,truth=false,prior=12.0
–resource:dbsnp,known=true,training=false,truth=false,prior=2.0

The numbers \(15\), \(12\) and \(2\) are the log-odds weights given to three catalogues. The mixture carries PRIOR_COUNTS = 20.0 and MAX_NUM_TRAINING_DATA = 2500000. Which variants survive filtering is determined by how strongly each catalogue is believed, and the belief is a command-line argument.

667.0.5 The thresholds

Scanning thirteen tools for adjudicating constants returns \(885\) assignments over \(588\) distinct names. The same decision carries different values across tools:

\[ \begin {array}{lll} \text {decision} & \text {tool} & \text {values in source} \\ \hline \text {min base quality} & \textsc {gatk} & 0,\ 4,\ 6,\ 10,\ 15,\ 20 \\ & \textsc {deepvariant} & 5,\ 10,\ 20 \\ & \textsc {dorado} & 0 \\ \text {min mapping quality} & \textsc {gatk} & -1,\ 0,\ 1,\ 10,\ 30,\ 50 \\ & \textsc {deepvariant} & 1,\ 10,\ 15,\ 20 \\ & \textsc {samtools}, \textsc {freebayes} & 0 \\ \text {min depth} & \textsc {gatk} & 4,\ 10 \\ & \textsc {dorado} & 0,\ 1,\ 3,\ 5 \\ & \textsc {bcftools} & 0,\ 1,\ 10 \\ \text {min allele fraction} & \textsc {gatk} & 0,\ 0.01,\ 0.5,\ 2.0 \\ & \textsc {dorado} & 3.0 \\ \text {beam width} & \textsc {bonito} & 1,\ 5,\ 32,\ 100 \\ \end {array} \]

A minimum mapping quality of \(50\) and one of \(0\) are both in the same codebase. Whether a read contributes to a call is a configuration choice, and the choices in use span the full range.

667.0.6 The truth set

Accuracy is reported against the Genome in a Bottle benchmark, which is a consensus across platforms and callers. Regions where the platforms disagree are excluded from the high-confidence intervals, and therefore from the evaluation.

A caller is scored only on the regions where callers already agree. The structure is that of §700.1, where \(262\) measured lines that could not be assigned to a level pair were recorded as UNKNWN and dropped from the closure count while remaining in the calibration list.

667.0.7 The chain
\[ \begin {array}{lll} \text {stage} & \text {operation} & \text {depends on} \\ \hline \text {current / fluorescence} & \text {raw signal} & \text {squiggle, trace} \\ \text {normalisation} & \text {median/MAD scaling} & \text {chosen statistic, kit version} \\ \text {basecall} & \text {CTC / HMM decode} & \text {weights} \leftarrow \text {reference-aligned reads} \\ Q & -10\log _{10}P & P \text { is that model's output} \\ \text {BQSR} & \text {reported} \to \text {empirical } Q & \text {mismatch} \equiv \text {error, given dbSNP} \\ \text {alignment} & \text {to GRCh38} & \leftarrow \text {earlier basecalls and assembly} \\ \text {variant call} & \texttt {min\_DP},\ \texttt {min\_AF},\ \texttt {MAPQ},\ \texttt {BQ} & \text {threshold choice} \\ \text {VQSR} & \text {Gaussian mixture} & \text {catalogue priors } 15,\ 12,\ 2 \\ \text {annotation} & \text {gene model} & \text {GENCODE} \leftarrow \text {prediction} + \text {curation} \\ \end {array} \]
667.0.8 A different reference, consistently

None of this is hidden, and none of it fails if changed. Substituting a different reference assembly, retraining the basecaller against it, rebuilding the known-sites catalogue from calls made under it, and recalibrating against that catalogue yields a pipeline that is internally consistent throughout: reads align, qualities recalibrate, variants pass the filters, and the accuracy against a truth set built the same way is high.

What would be different is the output. The same current traces would be read as a different string; the same positions would be called variant or reference according to which catalogue was consulted; and the agreement between stages would be as good as it is now, because the agreement is between stages that were fitted to one another.

667.0.9 Three ledgers
\[ \begin {array}{llll} & \text {observed} & \text {fitted by} & \text {origin fixed by} \\ \hline \text {NIST ASD} & \text {line differences} & \text {LOPT levels} & \text {ground state} = 0 \\ \text {AME2020} & \text {reaction } Q,\ \text {mass ratios} & \text {least-squares masses} & ^{12}\mathrm {C} = 12\ \mathrm {u} \\ \text {Sequencing} & \text {current, fluorescence} & \text {basecaller weights} & \text {the reference genome} \\ \end {array} \]

In each, only differences or relative quantities are recorded; absolute values are distributed by a fit; the origin is a stipulation; and the output of one generation is the standard against which the next is judged.

current / fluorescence (raw signal)
   \(\downarrow \) normalisation chosen statistic, kit version
   \(\downarrow \) basecall weights \(\leftarrow \) reference-aligned reads
\(Q = -10\log _{10}P\) \(P\) is that model’s output
   \(\downarrow \) BQSR mismatch \(\equiv \) error, given dbSNP
alignment to GRCh38 \(\leftarrow \) earlier basecalls and assembly
   \(\downarrow \) variant call min_DP, min_AF, MAPQ, BQ
   \(\downarrow \) VQSR catalogue priors 15, 12, 2
   \(\downarrow \) annotation GENCODE \(\leftarrow \) prediction + curation