Base editing quantification from Sanger traces (EditR equivalent)
base_edit_quantQuantify CBE/ABE base editing from a pair of Sanger traces — an unedited control and the edited pool — without NGS. At each editable position in the activity window the edited trace is treated as a mixture of the unedited and converted peaks, and the control's OWN alt-channel signal at that same position is subtracted as background, because dye crosstalk is position- and context-dependent and a global constant would be wrong per position. Significance comes from a null built from the same sample (every control position outside the window carrying the same base), so the threshold adapts to the run's chemistry instead of being hardcoded. Returns per-position percentages with z-scores, the target and its bystanders, the background distribution (including a robust estimate of its spread and a count of its outliers), and the noise floor — the percentage the background alone reaches, or null when the run's own null has no spread to derive one from. A window position whose control already carries the converted base is reported but not quantified, because the (1 − b) rescale amplifies error by 1/(1 − b) and turns a 0.1-point wobble into half the pool. Locate the window with an editor id plus the protospacer, or give it explicitly. Blind to indels, which shift the trace rather than mixing a base. PREDICTED, NOT MEASURED. None is published for this implementation. Every run instead reports what it rests on: the background mean, sd, robust (MAD-based) sd, outlier count and n, and a noiseFloorPercent that says how much apparent editing the background alone reaches at the significance threshold — null, rather than 0, when the run has no null with any spread to derive a limit from. This implementation's recovery of known synthetic mixtures (to under a percentage point) is deliberately NOT offered as validation — it tests the arithmetic and the coordinate handling, not whether the linear mixture model fits a real capillary trace. Two properties ARE characterised. The bias is directional and one-sided: the (1 − b) rescale assumes a fully converted position would read as alt fraction 1.0, which real chemistry does not reach, so percentages run low by roughly the crosstalk fraction (order 5-10% relative at typical 3% bleed). The variance is not constant across positions: dividing by (1 − b) amplifies the error in a and b by 1/(1 − b), so the variance of the estimate goes as 1/(1 − b)². Positions whose control alt fraction b exceeds 0.25 are therefore reported but NOT quantified, which bounds that amplification at 1.33x on everything the tool does quantify. Valid for: A pool edited by a cytosine or adenine base editor, read on the same amplicon and chemistry as an unedited control that starts within ±40 bases of it, where the editing is a SUBSTITUTION. Not valid for indels — a base editor also makes them, and an indel-bearing allele shifts the downstream trace so that it degrades the fit at every window position rather than showing up anywhere. Not valid where the control read already carries the alt base at a window position (a pre-existing variant, or the wrong control), since then there is nothing left to correct against — that condition is DETECTED rather than only described: a window position whose control alt fraction exceeds 0.25 is reported with an excludedReason and an editedPercent of 0 instead of a number, warned about, and failed by the hard control-supports-the-window-base-calls gate check. Reported percentages are pool-level: Sanger sees the superposition, so which allele carries which combination of bystander edits is not recoverable from it at all.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | No | Explicit-window mode: the base it converts to, as READ on the control strand. | |
| from | No | Explicit-window mode: the base the editor converts, as READ on the control strand (C for a CBE read forward, G for one read reverse). | |
| editor | No | Base editor id (be3, be4max, abe7.10, abe8e) — fixes the converted bases and the activity window in protospacer coordinates. Requires "protospacer". Mutually exclusive with the explicit window arguments. | |
| offset | No | Override the alignment offset between the reads (edited position p matches control position p + offset). Whole numbers only. By default it is found from the base calls outside the window; either way the identity reported back is the identity AT THE OFFSET USED, so overriding it does not hide a bad alignment behind the best-scoring one. | |
| windowEnd | No | Explicit window end, 1-based inclusive, in CONTROL coordinates. Window length is capped at 40. | |
| zThreshold | No | Significance threshold in standard deviations of the sample's own background. Must be between 1 and 10 — a value outside that range is REJECTED, not clamped, because a run silently retested at a threshold the caller did not choose looks exactly like one that was. Raising it raises the reported noise floor with it. | |
| editedBases | Yes | Base calls of the edited pool's read. | |
| protospacer | No | The 20-nt spacer, located in the CONTROL read. Found on either strand; a reverse-complement match numbers the protospacer right-to-left along the read and complements the converted bases (a CBE's C→T reads as G→A), which is handled. Must match exactly once. | |
| windowStart | No | Explicit window start, 1-based in CONTROL read coordinates. Requires windowEnd, from and to. | |
| controlBases | Yes | Base calls of the UNEDITED control read. | |
| editedChannels | Yes | Per-base [A, C, G, T] intensities of the edited read, same convention. | |
| targetPosition | No | 1-based CONTROL position of the intended edit. Give it when you know it: without it the most-edited significant position is labelled the target and the rest become bystanders, which relabels a bystander-dominant result as a clean one. | |
| controlChannels | Yes | Per-base [A, C, G, T] intensities of the control read, one row per called base, read at that base's peak location (trace arrays are indexed by scan, not by base). | |
| targetProtospacerPosition | No | 1-based protospacer position of the intended edit (PAM-distal = 1). Editor mode only. |