Lesson 7 of 13 · 11 min
Genome Assembly: De Novo vs Reference-Guided
When a DNA sequencing machine reads a sample, it does not hand you one long chromosome. It returns millions of short fragments called reads, each only about 100 to 300 letters (bases) of A, C, G, and T. Genome assembly is the process of stitching those overlapping reads back into the long, continuous sequence they came from, much like rebuilding a shredded document by matching the torn edges. Because two reads that came from the same spot in the genome share an overlapping stretch of sequence, software can line them up and merge them into longer pieces.
Contigs and Scaffolds
When the assembler merges overlapping reads, it produces a contig, short for contiguous sequence: an unbroken stretch of DNA with no gaps. A perfect assembly would give one contig per chromosome, but in practice you get many contigs because some regions cannot be joined confidently. A scaffold is the next level up: several contigs placed in their correct order and orientation, with the unknown gaps between them filled by the letter N, one N standing in for each estimated missing base. That ordering comes from paired-end reads, where both ends of a longer DNA fragment are sequenced so the assembler knows roughly how far apart two contigs sit.
Assembly Quality: N50 and Repeats
N50 is the standard way to describe how contiguous an assembly is. To compute it, sort every contig from longest to shortest, then add up their lengths one by one until the running total reaches half of the whole assembly's size. The length of the contig that tips you past that halfway point is the N50. A larger N50 means the genome is held together in fewer, longer pieces, which is usually better. For example, an N50 of 1,000,000 bases means half of the assembled genome sits in contigs that are at least a million bases long. Assembly is genuinely hard mainly because of repeats: stretches of sequence that recur many times, sometimes thousands of bases long. If a repeat is longer than a single read, no read can span it, so the assembler cannot tell which copy a read belongs to and must break the contig or collapse the copies. Short reads make this worse, which is why long reads tens of thousands of bases long improve assemblies so much.
De Novo Assembly with SPAdes
De novo assembly means building the genome from scratch using only the reads, with no reference genome to guide you (de novo is Latin for from new). It is the right choice when you are sequencing a new organism, a strain that differs a lot from any known genome, or when you specifically want to discover sequence a reference might be missing. SPAdes is a widely used de novo assembler for bacterial and other small genomes. In the command below, -1 and -2 give the forward and reverse read files from paired-end sequencing, --isolate tunes SPAdes for high-coverage single-isolate data, -t 8 lets it use 8 CPU threads, and -o names the output folder.
spades.py --isolate -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -t 8 -o spades_out===== Assembling finished. Used k-mer sizes: 21, 33, 55
* Corrected reads are in spades_out/corrected/
* Assembled contigs are in spades_out/contigs.fasta
* Assembled scaffolds are in spades_out/scaffolds.fasta
* Assembly graph is in spades_out/assembly_graph.fastg
* Paths in the assembly graph corresponding to the scaffolds are in spades_out/scaffolds.paths
======= SPAdes pipeline finished.
SPAdes log can be found here: spades_out/spades.log
Thank you for using SPAdes!
Reference-Guided Assembly
Reference-guided assembly takes a different route. Instead of building from scratch, you align (map) every read onto an existing reference genome from a closely related organism using an aligner such as BWA or minimap2, then read off the most common base at each position to produce the new genome. It is faster, needs far less memory, and works well when a good reference exists and your sample is similar to it, such as resequencing another human or another strain of the same bacterial species. Its weakness is that it can only reconstruct what the reference already contains: novel genes, large insertions, or rearrangements absent from the reference are easily missed. As a rule of thumb, reach for reference-guided assembly when a trustworthy, closely related reference is available, and for de novo assembly when it is not or when finding brand-new sequence is the whole point.
Try it yourself: grab a small E. coli read set from the SRA with fasterq-dump SRR2584866, assemble it with spades.py --isolate -1 SRR2584866_1.fastq -2 SRR2584866_2.fastq -o ecoli_out, then count how many contigs you produced with grep -c '>' ecoli_out/contigs.fasta (each > line is one contig header). Fewer, longer contigs, and a higher N50, mean a more contiguous assembly.