All protocols

Assemble a bacterial genome with SPAdes

De novo assemble a bacterial isolate from paired Illumina reads with SPAdes, then sanity-check contig count, total length, and N50 using seqkit.

SDSomenath DuttaUpdated July 21, 2026

Prerequisites

  • SPAdes installed (`spades.py` on your PATH)
  • Adapter- and quality-trimmed paired Illumina reads (R1/R2 FASTQ)
  • ~16-32 GB RAM available
  • seqkit installed for the size check

1Run the assembler

Assemble the paired reads in isolate mode, which is tuned for high-coverage bacterial isolates. -t sets threads and -m caps peak memory in GB; SPAdes runs read error correction, then staged per-K-mer assembly, and writes contigs.fasta and scaffolds.fasta into spades_out/.

bash
spades.py --isolate -1 R1.fastq.gz -2 R2.fastq.gz -o spades_out -t 8 -m 32

Expected output

Command line: /usr/local/bin/spades.py	--isolate	-1	R1.fastq.gz	-2	R2.fastq.gz	-o	spades_out	-t	8	-m	32

System information:
  SPAdes version: 3.15.5
  Python version: 3.10.9
  OS: Linux-5.15.0-91-generic-x86_64-with-glibc2.35

Output dir: /home/user/spades_out
Mode: read error correction and assembling
Debug mode is turned OFF

Dataset parameters:
  Isolate mode
  Reads:
    Library number: 1, library type: paired-end
      orientation: fr
      left reads: ['/home/user/R1.fastq.gz']
      right reads: ['/home/user/R2.fastq.gz']
Assembly parameters:
  k: automatic selection based on read length
  Repeat resolution is enabled
  Mismatch careful mode is turned OFF
Other parameters:
  Dir for temp files: /home/user/spades_out/tmp
  Threads: 8
  Memory limit (in Gb): 32

======= SPAdes pipeline started. Log can be found here: /home/user/spades_out/spades.log

===== Read error correction started.

== Running read error correction tool: /usr/local/bin/spades-hammer /home/user/spades_out/corrected/configs/config.info

===== Read error correction finished.

===== Assembling started.

== Running assembler: K21
== Running assembler: K33
== Running assembler: K55
== Running assembler: K77

===== Assembling finished. Used k-mer sizes: 21, 33, 55, 77

 * Corrected reads are in /home/user/spades_out/corrected/
 * Assembled contigs are in /home/user/spades_out/contigs.fasta
 * Assembled scaffolds are in /home/user/spades_out/scaffolds.fasta
 * Assembly graph is in /home/user/spades_out/assembly_graph_with_scaffolds.gfa

======= SPAdes pipeline finished.

SPAdes log can be found here: /home/user/spades_out/spades.log

Thank you for using SPAdes!

2Sanity-check the assembly size

Run seqkit stats with -a for the full statistics. Confirm num_seqs is a manageable number of contigs, sum_len lands near the expected genome size (~4.6-5 Mb for E. coli), and N50 is high — all signs of a clean, contiguous assembly.

bash
seqkit stats -a spades_out/contigs.fasta

Expected output

file                      format  type  num_seqs  sum_len    min_len  avg_len   max_len  Q1     Q2      Q3      sum_gap  N50      Q20(%)  Q30(%)  GC(%)
spades_out/contigs.fasta  FASTA   DNA   96        4,652,918  128      48,467.9  341,207  1,842  12,405  61,730  0        168,540  0.00    0.00    50.79

Troubleshooting

"== Error == The reads contain too many k-mers to fit into available memory" or the job is killed (out of memory)

If you have spare RAM, raise the limit with -m (in GB) — SPAdes reports roughly how much it needs and explicitly suggests increasing -m for the k-mer error. If instead the OS is killing the process, cap -m below your physical RAM so SPAdes self-limits, and lower the thread count, e.g. `-m 16 -t 4`. SPAdes peaks well above its average usage during graph construction.

Assembly is very fragmented (many short contigs, low N50)

Use --isolate for high-coverage isolates, or --careful for small genomes to reduce mismatches and short indels (note --isolate and --careful are mutually exclusive). Make sure the reads were adapter- and quality-trimmed before assembly — leftover adapters fracture the graph.

References