How Far Apart Do Sequencing Barcodes Need to Be?
6 min read · Updated October 30, 2026
A barcoded experiment fails in a way the data cannot show you. If two tags in the pool are one substitution apart, a single read error moves one sample's counts onto another's row — the totals still add up and the plot still looks like a result.
The defence is a minimum distance across the whole set, and it is the same coding theory that protects a barcode on a parcel. Here is what each distance buys and what it costs.
The rule, and what it means in reads
If every pair of barcodes in a set differs by at least d edits, then up to (d−1)/2 errors can be corrected and up to d−1 detected. The arithmetic is worth doing once: at d = 1 the barcodes are merely not identical, and nothing is corrected or detected. At d = 3, one error is corrected and two are detected. At d = 5, two errors are corrected.
Correcting means a read with one error is assigned to the right sample. Detecting means it is recognised as damaged and discarded rather than silently filed under a neighbour — which is the outcome that matters, because a misassigned read is indistinguishable from real signal.
Distance 3 is the usual working choice. Distance 1 is what you get by picking barcodes by hand and checking only that no two are the same.
What a distance costs in length
The space of barcodes satisfying a distance constraint shrinks fast as the barcodes get shorter, and the constraints you add for the chemistry — a GC window, a cap on homopolymer runs, the restriction sites you clone with — shrink it further.
Measured on a plate-sized request of 96 barcodes, with GC held between 25% and 75% and homopolymers capped at 3: 12-mers at distance 3 give all 96 comfortably, and so does a 384-plate. 12-mers at distance 5 still give 96. Ten-mers at distance 5 give 96. Eight-mers at distance 5 give 27 at the default seed — the search tried 58,263 candidates and ran out of room. Other seeds give 22 to 28, so the exact number is a property of the search rather than of the space; what is robust is that 96 is far out of reach at that length.
That is the trade in one line: a few extra bases of barcode buy an error-correction level that cannot be bought any other way.
A set that fell short looks exactly like a set that did not
A list of 27 barcodes is a list of barcodes. Nothing about the sequences says that 96 were requested, and nothing downstream will notice that a plate was filled with duplicates to make up the number.
So the figure to read is the distance ACHIEVED over the finished pool, re-derived from the barcodes themselves rather than assumed from the search that produced them, together with how many were actually built. A designer that quietly returns fewer, or that reports the distance it was asked for rather than the one it reached, is the failure mode this check exists for.
Hamming or Levenshtein, and why it is not a performance choice
Hamming distance counts substitutions only. Levenshtein counts substitutions, insertions and deletions. On a platform whose errors are overwhelmingly substitutions — Illumina — Hamming is adequate and faster to search. On nanopore or PacBio, where indels dominate, Hamming offers no protection at all against an insertion shifting one barcode into another.
The two are not interchangeable even on the same set. Asking for 96 twelve-mers at Hamming distance 3 returns a pool whose achieved Hamming distance is 4, because the substitution-only search packs the space differently — and that same pool has no guaranteed Levenshtein separation.
Choose by the error mode of the platform, not by which one runs faster.
Auditing a set you already have
Most barcode sets in use were inherited rather than designed. The useful question about one is not its average separation but its closest pair, because that pair is what will collide first.
A four-barcode set containing ACGTACGTACGT and ACGTACGTACGA has a minimum distance of 1: it corrects nothing and detects nothing, and the report names that pair. Everything else about the set — a GC range of 33% to 67%, no homopolymer longer than 2 — is fine, which is exactly why this has to be checked as a property of pairs rather than of barcodes.
Adding a second plate to barcodes already in use is the same problem: the new ones have to be distant from each other and from every existing one, so the existing set has to go into the design rather than be compared afterwards.
What distance does not protect against
- Index hopping. A free index primer attaching to the wrong library on a patterned flow cell produces a real, correct barcode on the wrong molecule, and no distance can detect it. Unique dual indexing is the defence.
- Contamination between samples before the barcode is attached.
- A barcode that is biased in the chemistry — extreme GC, a homopolymer run, or one that forms a hairpin with the adapter — which is a different set of constraints from distance.
- A barcode that contains the restriction site you clone with, which is a design constraint the search has to honour rather than something to filter for afterwards.
Frequently asked questions
What minimum distance should barcodes have?
Three, in most cases. A minimum edit distance of d corrects up to (d−1)/2 errors and detects up to d−1, so distance 3 corrects one error and detects two, and distance 5 corrects two. Distance 1 only means the barcodes are not identical and gives no protection at all.
Should I use Hamming or Levenshtein distance?
Levenshtein unless you know the platform's errors are substitutions. Hamming counts substitutions only, which is adequate on Illumina and offers nothing against the insertions and deletions that dominate nanopore and PacBio reads — an indel can shift one barcode into another and a Hamming-designed set will not have accounted for it.
Why did my barcode designer return fewer barcodes than I asked for?
Because the constraints left no room. Length, minimum distance, GC window and homopolymer cap together define a finite space, and short barcodes at a high distance run out quickly — a search for 96 eight-mers at distance 5 under a 25–75% GC window exhausts at 22 to 28 of them depending on the seed, where ten-mers give all 96. Lengthen the barcode or lower the distance.
Can I add new barcodes to a set I am already using?
Yes, if the existing ones go into the design as fixed members rather than being compared afterwards. The new barcodes have to be distant from each other and from every barcode already in use, and a set designed in isolation and then merged usually is not.
Related references
Related tools
Design a set of DNA barcodes that are pairwise far enough apart that a read error cannot turn one into another, or check a set you already have for the pair that will collide first.
Nearest-neighbor Tm, ΔG, hairpins and primer dimers for any oligo or primer pair.
Per-base quality, GC and length distributions, duplication levels, overrepresented sequences and adapter content, each with a warn/fail verdict.
Find the largest subset of your parts that share no long stretch of sequence, or design new ones that do not — the property that keeps a multi-part assembly stable and synthesisable.
Convert between FASTA, GenBank and tab-separated formats, and extract CDS or protein sequences.