LSMA

LONDON SCHOOL OF MULTIOMICS & AI

Free course

Free course

0 of 73 lessons

Lesson 6 of 9

Module 6 · Genome assembly

Long reads and repeats

Long reads and repeats

Long reads and repeats

Oxford Nanopore and PacBio read single DNA molecules thousands of bases long. A read longer than a repeat crosses it, so the assembler knows how the neighbouring pieces connect.

⏱ 13 min readModule 6 · Genome assemblyFree
Lesson at a glance4 steps · about 13 min
  1. Long reads today: HiFi and ultra-long
  2. Assemble the long reads with Flye
  3. Accuracy: polishing
  4. Two meanings of hybrid

The two long-read technologies work in different ways. In Oxford Nanopore sequencing, a single DNA strand is pulled through a tiny protein pore set in a membrane; the electric current through the pore changes with the bases inside it, and software translates the current trace into letters, a step called basecalling. In PacBio sequencing, a DNA polymerase copies a single molecule inside a tiny well and each added base gives off a flash of coloured light. Neither method cuts the DNA into short pieces first, so a read can be as long as the molecule that went in.

In Judging an assembly the short-read assembly came out correct but fragmented: five contigs, no misassemblies, and only 88% of the genome, because three copies of a 2 kb repeat collapsed into one. The cause was simple. No read or read pair was long enough to reach from unique sequence on one side of a repeat copy to the other. This lesson tests the obvious fix, reads longer than the repeat, and shows what it costs.

Short reads (Illumina)
  • 100–300 bases
  • Very accurate (about 0.1% errors)
  • Fragmented assemblies at repeats
Long reads (Nanopore, PacBio)
  • Thousands to hundreds of thousands of bases
  • Older nanopore reads: several % errors; PacBio HiFi and recent nanopore chemistry are far more accurate
  • Whole chromosomes in one contig

An error rate of 0.1% means about one wrong base in every 1,000; "several %" means several wrong bases in every 100. PacBio HiFi reads reach high accuracy by reading the same circular molecule many times over and combining the passes into one consensus read. The kinds of error differ too. Short-read errors are mostly substitutions, one letter read as another. Nanopore errors are more often indels, a base inserted or deleted, and they cluster in homopolymers, runs of the same letter such as AAAAAAA, where it is hard to tell from the current exactly how many identical bases passed through the pore. Keep that in mind when you read the accuracy figures below.

The kind of error matters as much as the rate. Random errors average out: if each read makes a different mistake at a position, the correct base still wins the vote once enough reads cover it. Errors that are systematic, made the same way by many reads, do not average out so well. A run of seven As may come out as six in a sizeable share of the reads, so extra coverage helps less than you might expect. That is why long-read assemblies keep small indel errors in homopolymers even at high depth, and why they are polished afterwards, as at the end of this lesson.

Long reads today: HiFi and ultra-long

Long-read technology has changed quickly, and "long reads" now covers several kinds of data with different jobs. HiFi reads are of moderate length but very accurate, so an assembler can trust each base. Ultra-long nanopore reads come from careful handling of very long DNA molecules and can reach a hundred thousand bases or more, long enough to cross the largest repeats in a human genome, such as the centromeres. The two complement each other: HiFi gives accuracy, ultra-long reads give reach. The first complete human genome, in Finishing and sharing a genome, used both.

How to read the table below

Each row is one kind of read. The lengths and accuracies are typical rounded values; they vary between runs and improve as the chemistry changes, so treat them as a guide to scale rather than as specifications. The last column says what each kind is mainly used for in assembly.

Read typeTypical lengthAccuracyMain role in assembly
Short reads (Illumina and similar)100–300 basesAbout 99.9%Cheap draft assemblies; polishing
PacBio HiFiAbout 10,000–25,000 basesAbove 99.9%Accurate contigs for large genomes
Nanopore, standardThousands to tens of thousands of basesAbout 99% with recent chemistry; lower with olderWhole bacterial genomes; spanning repeats
Nanopore, ultra-long100,000 bases and moreAs standard nanoporeCrossing the longest repeats

This module's practice long reads are standard nanopore reads: a few thousand bases each, from recent chemistry.

Assemble the long reads with Flye

Flye is an assembler built for long, error-prone reads. Rather than the exact k-mer graph of Assembly graphs, which a few percent of errors would break into fragments, it builds a repeat graph designed to tolerate read errors, and then uses the reads that cross each repeat to decide how the copies connect.

Terminal
seqkit stats data/bact_long.fastq.gz
flye --nano-hq data/bact_long.fastq.gz --out-dir flye_out --threads 2
cat flye_out/assembly_info.txt
file format type num_seqs sum_len min_len avg_len max_len data/bact_long.fastq.gz FASTQ DNA 148 959,152 1,319 6,480.8 20,026 #seq_name length cov. circ. repeat mult. alt_group graph_path contig_1 31753 34 N N 1 * *,1,*

What this does

  • seqkit stats summarises the long-read file, as in What genome assembly is for the short reads.
  • flye --nano-hq runs Flye and tells it the reads are high-quality nanopore reads from recent chemistry, so it can set its error model to match. Other options exist for older nanopore reads and for PacBio data; choosing the wrong one gives a poorer assembly. --out-dir flye_out is the output folder and --threads 2 uses two processor threads.
  • cat flye_out/assembly_info.txt prints Flye's summary table, one row per contig.

Reading the output

  • The seqkit line. There are only 148 reads, but they hold 959,152 bases. The shortest is 1,319 bases, the average 6,480.8 and the longest 20,026. Dividing by the genome size, 959,152 ÷ 31,950 ≈ 30, so the long reads give about 30× coverage, half the short-read coverage, from a hundredth as many reads.
  • Read length is a distribution. The average says less than you might think, because a few very long reads can sit alongside many short ones. Long-read runs are therefore usually summarised by the read N50, the same calculation as the contig N50 of Judging an assembly, applied to reads: half the bases are in reads at least this long. For crossing repeats, what counts is how many reads are longer than the repeat, not the mean.
  • The assembly_info table. Each column describes one contig: its name, its length (31,753 bases), its mean coverage (34), whether Flye found it to be circular (N, no), whether it is itself a repeat (N), and its multiplicity, the number of copies it represents (1). The last two columns record alternative versions and the path the contig follows through Flye's graph.

One contig of 31,753 bases, nearly the whole genome, from 148 reads. The 2 kb repeat is no longer a problem: most reads are longer than it. A real bacterial genome is usually circular, which Flye reports in the circ. column.

About 30× is at the modest end for long-read assembly. Because each long read carries more errors than a short read, the assembler needs enough reads at each position to outvote them, and runs with too little coverage tend to leave more indels behind or break in low-coverage stretches. With a small genome and a single repeat type, as here, 30× is enough to give one contig.

Flye is one of several current long-read assemblers, named here as examples only. Canu works with noisy or accurate long reads. hifiasm was designed for HiFi reads and can keep the two parental copies of each chromosome apart; it can also take ultra-long or Hi-C data. Verkko combines HiFi with ultra-long nanopore reads to build complete chromosomes. No single assembler is best for every genome; what matters most is choosing one built for your reads, setting it for your read type, and checking the result as in Judging an assembly.

Compare this with Short-read assembly with SPAdes. There, read pairs about 400 bases apart could never reach across the 2,000-base repeat, so SPAdes stopped at each end of it. Here the shortest read, 1,319 bases, is still shorter than the repeat, but the average read is over three times longer than it. Any read that begins in unique sequence on one side, runs through a repeat copy and ends in unique sequence on the other side shows exactly which pieces belong together.

Long reads and repeats · LSMA free course Top: read pairs spanning about 400 bases cannot cross a 2,000-base repeat; pairs inside it could come from any copy. Bottom: long reads of several thousand bases start and end in unique sequence on either side of the repeat, so they show how the neighbouring pieces connect. 1 · SHORT READ PAIRS STOP INSIDE THE REPEAT repeat · 2 kb Each pair spans about 400 bases; none reaches from one side of the repeat to the other. 2 · LONG READS CROSS IT repeat · 2 kb A read longer than the repeat is anchored in unique sequence at both ends.
Short read pairs that fall inside the repeat (pale) could have come from any copy. A long read that starts and ends outside the repeat leaves no doubt about which pieces join. Lengths are drawn roughly to the lesson's numbers; schematic.

Flye is described by Kolmogorov, Yuan, Lin and Pevzner (2019, Nature Biotechnology). PacBio HiFi reads were introduced by Wenger et al. (2019, Nature Biotechnology); hifiasm is Cheng et al. (2021, Nature Methods); Unicycler is Wick, Judd, Gorrie and Holt (2017, PLOS Computational Biology). The accuracy figures in the table are rounded and change quickly as chemistry and basecalling software improve, so cite any such figure with its year. For nanopore data, also report the basecaller and model, since these affect accuracy, and give Flye's version and read-type option.

Accuracy: polishing

A single contig answers the contiguity question. The next question is correctness, and for that you compare the Flye contig with the true genome, using QUAST exactly as in Judging an assembly.

Terminal
quast.py flye_out/assembly.fasta -r data/practice_bacterium.fa -o quast_flye
grep -E "^# contigs  |^Genome fraction|mismatches per|indels per" quast_flye/report.txt
# contigs 1 Genome fraction (%) 99.405 # mismatches per 100 kbp 28.34 # indels per 100 kbp 50.38

What this does and what it shows

The first line compares the Flye assembly, flye_out/assembly.fasta, with the true genome and writes the report to quast_flye. The second keeps four lines of the report, now including indels per 100 kbp, the number of small insertions and deletions per 100,000 bases. The output says: one contig, covering 99.405% of the genome, with about 28 single-base mismatches and about 50 small indels per 100,000 bases. The structure is nearly perfect; the fine detail is not. As a rough consensus quality, the method from Judging an assembly gives (28.34 + 50.38) ÷ 100,000 ≈ 0.00079 errors per base, or QV ≈ 31, against about QV 41 for the short-read assembly.

Worked example · short versus long, side by side

short reads (SPAdes): 5 contigs · 88.1% of genome · 7 mismatches and 0 indels per 100 kb
long reads (Flye): 1 contig · 99.4% · 28 mismatches and 50 indels per 100 kb
across this 32 kb genome: about 9 mismatches and 16 small insertions or deletions

Each indel inside a gene can shift the reading frame and break it. Polishing fixes them: with the long reads (Medaka for nanopore), then with accurate short reads (Polypolish or Pypolca). Combining both read types is called a hybrid approach.

Step by step. The rates are per 100,000 bases, and the contig is 31,753 bases, which is 0.31753 of 100,000. So the mismatches are 28.34 × 0.31753 ≈ 9.0, and the indels are 50.38 × 0.31753 ≈ 16.0.

Why indels matter more. A gene is read three bases at a time, in codons. Think of a sentence of three-letter words: THE CAT ATE THE RAT. Delete one letter, the first E, and the rest regroups as THC ATA TET HER AT: every word after the deletion is wrong. A mismatch, by contrast, changes one letter of one word and leaves the rest intact. One indel in a gene usually garbles every amino acid after it and soon hits a stop codon, so a gene finder will report a broken, shortened gene. Sixteen indels in a 32 kb genome with about 30 genes could damage many of them.

What polishing does. A polisher lines the reads up against the draft assembly and, at each position, corrects the assembly to what most of the reads say. Medaka does this with the nanopore reads themselves; Polypolish and Pypolca then use the very accurate short reads to fix the errors that remain.

Why this order. Long reads go first because they can be placed uniquely almost everywhere, including across repeats, so they can fix the larger and clustered errors. Short reads come second because they are the most accurate base by base, so they clean up the small errors that remain. One rule applies to both: the polishing reads must come from the same DNA, ideally the same extraction, as the assembly. Short reads from a different culture of the "same" strain may carry genuine differences, and a polisher would copy them into the genome as if they were corrections.

Go deeper: polishing in repeats, and polishing too much

A polisher is only as good as the read placements it is given. Inside a repeat, a short read could belong to any copy, and aligners usually choose one of the equally good places at random. If the copies differ by a few bases, reads from one copy can then “correct” another copy into the wrong sequence. Polypolish was designed around this problem: it uses every possible placement of each read and changes a base only where the reads agree overwhelmingly.

A second trap is running a polisher round after round in the hope of more improvement. After a round or two the real errors are gone, and further rounds can start making unwanted changes in the hardest regions. Judge each round with a measure such as QUAST against a reference, or Merqury's QV, as in Judging an assembly, and stop when it no longer improves.

Two meanings of hybrid

The word hybrid is used in two ways. A hybrid assembler, such as Unicycler, takes short and long reads together from the start: in its usual mode it builds the graph from the accurate short reads, then uses the long reads to find the right route through each repeat. The other route, the one in this lesson, assembles the long reads alone and uses the short reads only to polish. As nanopore accuracy has improved, the long-read-first route has become the usual one for bacteria. With HiFi reads, which are already very accurate, short-read polishing is often not needed at all.

Which data to buy depends on the question. If you only need to know which genes an isolate carries, a short-read draft like the one from Short-read assembly with SPAdes is often enough, and it is cheap. If you need the order of genes, the full set of plasmids or the exact copy number of a repeat, long reads are worth the extra cost and effort, because no amount of short-read data will resolve a repeat longer than the read pairs. The next lesson, Genes on your assembly, shows why indel errors matter so much when you look for genes.

Key point

For a complete bacterial genome today, the usual recipe is long reads for structure, then polishing with short reads for accuracy.

Consider a second example, a hospital investigating an outbreak of a resistant bacterium. Long reads show whether a resistance gene sits on the chromosome or on a plasmid that could pass to other bacteria, a question fragmented short-read assemblies often cannot answer. Short-read polishing then makes the sequence exact, so that isolates from different patients can be compared base by base. Each read type answers the question the other cannot.

Further reading · Module 6Flye usage guide: read-type settings and the assembly_info columns. · The hifiasm documentation: assembly from HiFi, ultra-long and Hi-C data. · Unicycler: hybrid assembly of bacterial genomes. · Medaka: polishing with nanopore reads. · All reading for this course

Check your understanding

1. Why did Flye give one contig where SPAdes gave five?

2. What does polishing fix?

3. Why do indels matter more than mismatches in genes?

Up next

Lesson 7

Genes on your assembly: a first count, and is it complete?

Ask BioTutor

Create a free website with Framer, the website builder loved by startups, designers and agencies.