Skip to content

Assembly QC

The assembly QC stage combines structural metrics, marker-based genome-quality estimates and read-mapping statistics:

Question Tool Answers with
How contiguous is the assembly? QUAST 5.3.0 contig count, N50, largest contig, total length, GC
What are the marker-based completeness and contamination estimates? CheckM 1.2.5 completeness %, contamination %, from lineage-specific single-copy markers
How do the reads map to the assessed assembly? Qualimap 2.3 mean depth, evenness, GC bias, mapping rate, insert size
Does the genome still carry sequencing adapters or barcodes? BLAST+ 2.17.0 adapter loci at contig ends and inside contigs

QUAST, CheckM and the adapter screen need a genome; Qualimap needs the BAM that decontamination already made for BlobTools. All five results — these four plus GTDB-Tk — end up in the MultiQC report in 09.report.

Everything here is in workflow/rules/shared/20_qc.smk and runs in all four modes, except Qualimap.

Terms used on this page

QC quality control
N50 the contig length at which half the assembly sits in contigs that long or longer
ONT Oxford Nanopore Technologies, the long-read sequencing platform

Interpret QC with the filtering history

Decontamination removes contigs according to parameters.decontamination.mode. In hybrid it filters the Illumina SPAdes draft; the delivered ONT genome gets a second screen that writes a verdict per contig and removes nothing (long_read_mode, default off). Read contaminants/contig_taxonomy_decisions.tsv, and in hybrid also contaminants/{sample}_final_contig_taxonomy_decisions.tsv, beside the CheckM numbers, since both retained contamination and removal of genuine sequence can affect the estimates.

Staging: one genome, or two

Rule stage_qc_genomes.

Three modes deliver one genome per sample. hybrid delivers the ONT + Polypolish genome and keeps the decontaminated Illumina draft, so the two can be compared directly. Rather than duplicate rule bodies or add a wildcard, one small bookkeeping rule copies this sample's assemblies into a temporary directory under controlled names, and QUAST, CheckM and GTDB-Tk all read that one directory.

Mode Staged as Role
illumina, nanopore, contigs {sample}.fasta primary
hybrid {sample}_illumina.fasta comparator (the decontaminated SPAdes draft)
hybrid {sample}_ont.fasta primary (the delivered genome)

Those basenames become the ids CheckM, GTDB-Tk and QUAST report under, so they come from a single list rather than being typed out per tool. The staging directory itself is temporary and Snakemake removes it once the last consumer is finished.

Beside it sits a file that is kept: 02.assembly/{sample}/eval/{sample}_qc_genomes.tsv, with columns bin_id, role, technology, source_path. It says which of the two hybrid rows is the delivered genome, so nobody has to infer it from a filename suffix. No rule reads it; it exists to be read by a person.

A hybrid sample does twice the work inside one job

CheckM and GTDB-Tk each process both genomes in a single run, under one thread reservation. Expect roughly double the wall-clock of a single-genome mode for those two rules.

Assembly metrics (QUAST)

Rule genome_assembly_evaluation.

quast eval/genomes/*.fasta -o eval/quast --no-icarus -t {threads}

QUAST reports the structural quality of the assembly. It says nothing about biological completeness — that is CheckM's job — but it says how fragmented the assembly is, and fragmentation limits everything downstream that depends on gene context. The mobilome module in particular is built around that constraint; see Draft assemblies.

The shell globs *.fasta inside the staged directory, so a hybrid sample gets both assemblies side by side in one report. --no-icarus skips the interactive contig browser, which nothing here consumes.

Output: 02.assembly/{sample}/eval/quast/ (QUAST names the files inside it).

QUAST labels an assembly by the input file's basename, so the labels are {sample}, or {sample}_illumina and {sample}_ont in hybrid. The MultiQC report renames them to assembly QC | {sample}, or assembly Illumina QC / assembly ONT QC.

Completeness and contamination (CheckM)

Rule completeness_and_contamination.

CheckM places the genome in its reference tree, picks the set of single-copy marker genes for that lineage, and counts them.

  • Markers missing → an incomplete assembly.
  • Markers present in more copies than expected → either contamination (more than one organism in the bin) or a genuine duplication.

These estimates support genome-quality assessment; BacFlux does not turn them into a universal pass/fail decision.

checkm lineage_wf -t {threads} -x fasta eval/genomes/ eval/checkm/
checkm qa -o 2 -t {threads} --tab_table -f {sample}_checkm_stats.tsv lineage.ms eval/checkm/

lineage_wf places the genome and counts markers; qa -o 2 --tab_table writes the extended per-bin statistics as a parsable TSV. CheckM takes several "bins" in one run and reports a row for each, which is how the two hybrid genomes are handled.

Output What it is
eval/checkm/ CheckM's own working and result tree
eval/checkm/{sample}_checkm_stats.tsv the table MultiQC reads
eval/checkm/lineage.ms the marker-set file lineage_wf writes and qa reads back — the name is CheckM's

Reading the two numbers together is what makes them useful:

Completeness Contamination Usual meaning
high low a good isolate genome
high high Possible retained contamination or marker duplication; inspect the supporting evidence
low low Incomplete assembly, possibly including excessive filtering; review removed sequence
low high Both estimates warrant investigation; review reads, assembly and filtering

The third row is the one to watch for after a large-removal warning from the selector.

Mapping quality (Qualimap)

Rule map_evaluation — modes with reads only.

Qualimap summarises how a sample's reads sit on its own assembly: mean depth and how even it is, GC bias, mapping rate, and insert size for paired reads. Uneven or unexpectedly low coverage is an early warning of a mixed culture, a mis-assembly, or not enough data.

qualimap bamqc -bam {sample}_map.bam --java-mem-size={N}G -nt {threads} \
  -outdir eval/qualimap -outformat html

{N} is Qualimap's Java heap, the most memory Java may use: resources.ram_gb minus 4 GB, at most 64 GB (see Resources). Before Qualimap starts, the rule clears two settings a login script or a cluster module may have left behind. JAVA_OPTS, when set, is taken by Qualimap's start script as the whole list of Java options, and --java-mem-size would be ignored. DISPLAY makes Java try to open a screen to draw its charts, which fails at the report-writing step when there is none. The rule tells Java instead that there is no screen (-Djava.awt.headless=true, through JAVA_TOOL_OPTIONS), which Java confirms in the log with a line beginning Picked up JAVA_TOOL_OPTIONS.

Input is the decontamination BAM — Bowtie2 in the short-read modes, minimap2 map-ont in nanopore. That BAM is temporary, so this rule's dependency on it is what keeps it alive long enough to be used twice.

Output: 02.assembly/{sample}/eval/qualimap/, an HTML report directory.

The rule is gated on the mode having reads, so contigs mode has no Qualimap report. That mode does have a BAM, but it is the contigs aligned against themselves purely to satisfy BlobTools; a mapping-quality report on a self-alignment would say nothing. It is a mode-specific absence, not a gap.

In hybrid, this panel is Illumina coverage of the Illumina draft

The BAM comes from the short-read branch of decontamination: Illumina reads mapped to the pre-decontamination SPAdes draft. This Qualimap panel does not assess ONT read mapping. Therefore this is not coverage of the delivered ONT genome, and MultiQC labels the panel mapping Illumina QC to say so. The QUAST, CheckM and GTDB-Tk panels are technology-tagged for the same reason.

Where the two hybrid assemblies get compared

Three places, answering different questions:

Where Comparison
eval/quast/ both assemblies in one QUAST report — contiguity, length, GC
eval/checkm/ and 03.taxonomy/ one row per genome — completeness, contamination, lineage
02.assembly/{sample}/snps/SNPs_summary.txt Snippy variant counts for each ONT polishing stage against the decontaminated Illumina assembly as reference; see Hybrid mode

Adapter screen (BLAST)

Sequencing adapters and barcodes left in the reads end up in the assembly wherever many reads end at the same place, which is at the ends of linear contigs. The screen searches the finished genome, contigs_final.fasta, for ONT adapters and barcodes, PacBio and MGI adapters, Illumina adapters (downloaded from NCBI UniVec by rule univec_illumina) and, for ONT reads BacFlux trimmed, the very sequence that was trimmed. It reports and removes nothing.

Rule Does
univec_illumina once per output folder: downloads NCBI UniVec, checks its SHA-256 checksum and keeps the 151 Illumina records
adapter_search_input joins every adapter into one query file, and extends each circular contig by its own first 200 bp so that an adapter across the contig's start is seen
blast_adapters blastn -task blastn-short, adapters against the genome
screen_adapters keeps hits of at least 90 % identity, at least 20 bp long within 100 bp of the end of a linear contig or 28 bp long inside a contig, merges them into loci, and writes the Adapters table of the MultiQC report

A circular contig has no ends, so every hit on it is judged as internal. A locus made only of the 50 bp that follow every ONT rapid barcode, which are the right end of phage Mu, is listed but not counted inside a contig, because a Mu prophage holds the same sequence. The method, its thresholds and its limits are explained in ONT adapter trimming and the adapter screen.

Before a GenBank submission

The screen covers the common adapters only. NCBI provides its own adaptor screen, FCS-adaptor, to clean genomes before submission; run it on the genome before you submit.

Resources

Rule Threads Memory
stage_qc_genomes 1 negligible — mkdir and cp
genome_assembly_evaluation capped at 24 modest
completeness_and_contamination capped at 24 tens of GB; pplacer is the driver
map_evaluation capped at 24 a Java heap of resources.ram_gb minus 4 GB, at most 64 GB and at least 1 GB; the 4 GB are left for what Java needs beyond its heap
adapter_search_input, blast_adapters, screen_adapters 1 negligible; BLAST takes seconds on a bacterial genome

"Capped at 24" means the rule asks for min(resources.threads, 24), and --cores caps what Snakemake then grants it. Qualimap's memory figure is a Java heap size in gigabytes, not a core count, which is why it is a resource (java_mem) rather than a thread count; Snakemake only schedules against it if the launch line passes --resources java_mem=N, which also lowers each heap to N GB. On a cluster the job asks the scheduler for the heap plus 4 GB, never more than ram_gb. See Running BacFlux.

CheckM and GTDB-Tk both run pplacer and each can use tens of GB, so the taxonomy rule deliberately waits for CheckM rather than running alongside it on the same sample.

Output files

All under 02.assembly/{sample}/eval/.

Path Kept? Read by
{sample}_qc_genomes.tsv yes you — which genome is which
quast/ yes MultiQC
checkm/{sample}_checkm_stats.tsv yes MultiQC
checkm/ (tree, lineage.ms) yes checkm qa
qualimap/ yes MultiQC; absent in contigs mode
genomes/ no QUAST, CheckM, GTDB-Tk — deleted once all three are done
adapter_screen/{sample}_adapter_loci.tsv yes you — one row per adapter locus, with counted and reason columns
adapter_screen/{sample}_adapter_screen_mqc.tsv yes MultiQC (the Adapters table)
adapter_screen/{sample}_adapter_blast.tsv yes screen_adapters; every BLAST hit, also those that do not pass the rules
adapter_screen/{sample}_adapter_query.fasta yes screen_adapters; every adapter searched for
adapter_screen/{sample}_search_contigs.fasta no blast_adapters — the genome with circular contigs extended

UniVec's Illumina records sit once per output folder in 02.assembly/adapter_lists/, with a PROVENANCE.txt saying where and when they were downloaded.

What to check afterwards

  • CheckM completeness and contamination first. Everything downstream inherits the quality of the genome, and the two numbers together tell you which way a problem points.
  • QUAST's contig count and N50. A fragmented assembly is not wrong, but it limits what the gene-context stages can say — the mobilome module reports contig-edge flags on every row precisely because of this.
  • Qualimap's mean depth and evenness. A bimodal depth distribution on a single-isolate assembly usually means more than one organism, or a plasmid at high copy number.
  • The Adapters table. Adapter at a contig end needs trimming before a submission; a match inside a contig is worth a look in the locus table, whose reason column says how each locus was judged.
  • 09.report/multiqc_report.html — all of the above for the whole batch on one page.