De novo Assembly
Overview
After trimming and quality checking sequencing reads, the next step is to reconstruct the bacterial genome from short sequencing reads. This process is called genome assembly.
In this lesson, we will use trimmed paired-end reads to perform de novo genome assembly. De novo assembly means that we assemble the genome without using a reference genome.
Learning objectives
By the end of this lesson, you should be able to:
- explain what genome assembly means
- understand the difference between raw reads and contigs
- run a bacterial genome assembly using
SPAdes - identify the main assembly output files
- organize assembly outputs into a clean directory structure
- prepare assembly files for downstream quality control
Activate the assembly environment
If you are continuing from the previous trimming lesson, you may still be in the qc environment. For assembly, we need a different environment named ’assembly. First we will deactivate qc environment to safely exit.
conda deactivateIt will return to base environment
(base) genomevm@genome-clone-vm2:~tanzim$
Now activate assembly environment:
conda activate assembly(assembly) genomevm@genome-clone-vm2:~tanzim$
Check that spades.py is available:
spades.py --version(assembly) genomevm@genome-clone-vm2:~tanzim$
SPAdes genome assembler v4.2.0
If the command works, you should see the installed SPAdes version.
Let’s check for manuals quickly.
spades.py --helpInput files
For genome assembly, we will use the paired trimmed reads generated in the previous lesson.
trimmed_reads/S1_trim_R1.fastq.gz
trimmed_reads/S1_trim_R2.fastq.gz
Check that the files are present:
ls trimmed_readsYou should see:
S1_trim_R1.fastq.gz
S1_trim_R2.fastq.gz
For paired-end assembly, use the paired trimmed reads:
S1_trim_R1.fastq.gz
S1_trim_R2.fastq.gz
Do not use the unpaired files unless your instructor specifically asks you to include them.
What is genome assembly?
Genome assembly is the process of joining sequencing reads together to create longer sequences.
These longer sequences are called contigs.
Short reads → contigs → draft genome assembly
Because bacterial genomes are usually a few million base pairs long, short reads cannot cover the whole genome in one piece. Instead, the assembler reconstructs the genome as multiple contigs.
Create an assembly output folder
Create a folder for assembly results:
mkdir -p assemblyRun SPAdes
Run SPAdes using the trimmed paired-end reads:
spades.py \
-1 trimmed_reads/S1_trim_R1.fastq.gz \
-2 trimmed_reads/S1_trim_R2.fastq.gz \
-o assembly/S1_spades \
-t 4Understanding the command
| Option | Meaning |
|---|---|
spades.py |
Runs the SPAdes assembler |
-1 |
Forward paired-end reads |
-2 |
Reverse paired-end reads |
-o |
Output directory |
-t 4 |
Use 4 CPU threads |
If your computer or server has more available CPUs, you can increase the number after -t.
For example:
-t 8Check assembly outputs
After SPAdes finishes, list the output directory:
ls assembly/S1_spadesYou should see files and folders such as:
contigs.fasta
scaffolds.fasta
assembly_graph.fastg
spades.log
The most important output for this training is usually:
assembly/S1_spades/contigs.fasta
Important SPAdes output files
| File | Description |
|---|---|
contigs.fasta |
Main assembled contig file |
scaffolds.fasta |
Scaffolded assembly file |
spades.log |
Log file from the assembly run |
assembly_graph.fastg |
Assembly graph file |
For most downstream bacterial genome analysis in this course, we will use:
contigs.fasta
Inspect the assembly file
A FASTA file contains sequence names and nucleotide sequences.
View the first few lines of the assembly:
head assembly/S1_spades/contigs.fastaA FASTA file looks like this:
>NODE_1_length_355368_cov_93.924892
TATGAGGTGATGATATCACCTCTAACTAAGTGACC....
>NODE_2_length_343701_cov_97.093919
GATTCCATCCCGAACTCAGAAGTGAAACGAAACAG....
Each sequence starts with a header line beginning with >.
Count the number of contigs
To count the number of contigs in the assembly:
grep -c "^>" assembly/S1_spades/contigs.fastaThis counts the number of FASTA headers.
270
Does your assembly contain one contig or multiple contigs?
Most short-read bacterial genome assemblies contain multiple contigs. A smaller number of contigs usually suggests a more continuous assembly, but quality should be checked using assembly QC tools.
Copy the final assembly file
To make downstream analysis easier, create a folder for final assemblies:
mkdir -p assembliesCopy the SPAdes contig file into this folder with a clear sample name:
cp assembly/S1_spades/contigs.fasta assemblies/S1_contigs.fastaCheck the copied file:
ls assembliesYou should see:
S1_contigs.fasta
Open the downloaded file using a text editor such as Notepad++, VS Code, or another FASTA viewer.
Use:
open S1_contigs.fastaUse:
xdg-open S1_contigs.fastaFinal directory structure
At the end of this lesson, your directory should look like this:
.
├── raw_reads
│ ├── S1_R1.fastq.gz
│ └── S1_R2.fastq.gz
├── trimmed_reads
│ ├── S1_trim_R1.fastq.gz
│ └── S1_trim_R2.fastq.gz
├── qc_reports
│ ├── S1_trim_R1_fastqc.html
│ ├── S1_trim_R1_fastqc.zip
│ ├── S1_trim_R2_fastqc.html
│ └── S1_trim_R2_fastqc.zip
├── assembly
│ └── S1_spades
│ ├── contigs.fasta
│ ├── scaffolds.fasta
│ └── spades.log
└── assemblies
└── S1_contigs.fasta
Key points
- Genome assembly reconstructs longer genome sequences from short sequencing reads.
SPAdesis commonly used for bacterial de novo genome assembly.- The main output file is usually
contigs.fasta. - Rename and copy the final contig file to a separate
assembliesfolder. - The assembly file will be used in the next lesson for assembly quality control.
Next step
In the next lesson, we will assess the quality of the assembled genome using assembly QC tools.