Skip to main content

bactopia

Tags: bacteria assembly annotation amr mlst genomics pipeline named-workflow

Comprehensive bacterial analysis pipeline for complete genomic characterization.

This workflow performs end-to-end analysis including quality control, assembly, annotation, antimicrobial resistance detection, MLST typing, and optional pathogen-specific analysis through Merlin. It processes raw sequencing reads and produces a complete genomic characterization suitable for downstream analysis.

Pipeline Overview

Bactopia Workflow

Looking at the workflow overview above, it might not look like much is happening, but I can assure you that a lot is going on. The workflow is broken down into 8 steps, which are:

  1. Gather - Collect all the data in one place
  2. QC - Quality control of the data
  3. Assembler - Assemble the reads into contigs
  4. Annotator - Annotate the contigs
  5. Sketcher - Create a sketch of the contigs, and query databases
  6. Sequence Typing - Determine the sequence type of the contigs
  7. Antibiotic Resistance - Determine the antibiotic resistance of the contigs and proteins
  8. Merlin - Automatically run species-specific tools based on distance

If you are looking for a guide to get started quickly, please check out the Beginner's Guide.

Step 1 - Gather

The main purpose of the gather step is to get all the samples into a single place. This includes downloading samples from ENA/SRA or NCBI Assembly. The tools used are:

ToolDescription
artFor simulating error-free reads for an input assembly
fastq-dlDownloading FASTQ files from ENA/SRA
ncbi-genome-downloadDownloading FASTA files from NCBI Assembly

This gather step also does basic QC checks to help prevent downstream failures.

Failed Quality Checks

FilenameDescription
-gzip-error.txtSample failed Gzip checks and excluded from further analysis
-low-basepair-proportion-error.txtSample failed basepair proportion checks and excluded from further analysis
-low-read-count-error.txtSample failed read count checks and excluded from further analysis
-low-sequence-depth-error.txtSample failed sequenced basepair checks and excluded from further analysis
Poor samples are excluded to prevent downstream failures

Samples that fail any of the QC checks will be excluded from further analysis. Those samples will generate a *-error.txt file with the error message. Excluding these samples prevents downstream failures that cause the whole workflow to fail.

Example Error: Input FASTQ(s) failed Gzip checks

If input FASTQ(s) fail to pass Gzip test, the sample will be excluded from further analysis.

Example Text from <SAMPLE_NAME>-gzip-error.txt <SAMPLE_NAME> FASTQs failed Gzip tests. Please check the input FASTQs. Further analysis is discontinued.

Example Error: Input FASTQs have disproportionate number of reads

If input FASTQ(s) for a sample have disproportionately different number of reads between the two pairs, the sample will be excluded from further analysis. You can adjust this minimum read count using the --min_proportion parameter.

Example Text from <SAMPLE_NAME>-low-basepair-proportion-error.txt <SAMPLE_NAME> FASTQs failed to meet the minimum shared basepairs. They shared Y basepairs, with R1 having A bp and R2 having B bp. Further analysis is discontinued.

Example Error: Input FASTQ(s) has too few reads

If input FASTQ(s) for a sample have less than the minimum required reads, the sample will be excluded from further analysis. You can adjust this minimum read count using the --min_reads parameter.

Example Text from <SAMPLE_NAME>-low-read-count-error.txt <SAMPLE_NAME> FASTQ(s) contain X total reads. This does not exceed the required minimum Y read count. Further analysis is discontinued.

Example Error: Input FASTQ(s) has too little sequenced basepairs

If input FASTQ(s) for a sample fails to meet the minimum number of sequenced basepairs, the sample will be excluded from further analysis. You can adjust this minimum read count using the --min_basepairs parameter.

Example Text from <SAMPLE_NAME>-low-sequence-depth-error.txt <SAMPLE_NAME> FASTQ(s) contain X total basepairs. This does not exceed the required minimum Y bp. Further analysis is discontinued.

Step 2 - QC

The qc module uses a variety of tools to perform quality control on Illumina and Oxford Nanopore reads. The tools used are:

ToolTechnologyDescription
bbtoolsIlluminaA suite of tools for manipulating reads
fastpIlluminaA tool designed to provide fast all-in-one preprocessing for FastQ files
fastqcIlluminaA quality control tool for high throughput sequence data
fastq_scanNanoporeA tool for quickly scanning FASTQ files
lighterIlluminaA tool for correcting sequencing errors in Illumina reads
NanoPlotNanoporeA tool for plotting long read sequencing data
nanoqNanoporeA tool for calculating quality metrics for Oxford Nanopore reads
porechopNanoporeA tool for removing adapters from Oxford Nanopore reads
rasusaNanoporeRandomly subsample sequencing reads to a specified coverage

Similar to the gather step, the qc step will also stop samples that fail to meet basic QC checks from continuing downstream.

Failed Quality Checks

FilenameDescription
.error-fastq.gzA gzipped FASTQ file of reads that failed QC
-low-read-count-error.txtSample failed read count checks and excluded from further analysis
-low-sequence-coverage-error.txtSample failed sequenced coverage checks and excluded from further analysis
-low-sequence-depth-error.txtSample failed sequenced basepair checks and excluded from further analysis
Poor samples are excluded to prevent downstream failures

Samples that fail any of the QC checks will be excluded from further analysis. Those samples will generate a *-error.txt file with the error message. Excluding these samples prevents downstream failures that cause the whole workflow to fail.

Example Error: After QC, too few reads remain

If after cleaning reads, a sample has less than the minimum required reads, the sample will be excluded from further analysis. You can adjust this minimum read count using the --min_reads parameter.

Example Text from <SAMPLE_NAME>-low-read-count-error.txt <SAMPLE_NAME> FASTQ(s) contain X total reads. This does not exceed the required minimum Y read count. Further analysis is discontinued.

Example Error: After QC, too little sequence coverage remains

If after cleaning reads, a sample has failed to meet the minimum sequence coverage required, the sample will be excluded from further analysis. You can adjust this minimum read count using the --min_coverage parameter.

Note: This check is only performed when a genome size is available.

Example Text from <SAMPLE_NAME>-low-sequence-coverage-error.txt After QC, <SAMPLE_NAME> FASTQ(s) contain X total basepairs. This does not exceed the required minimum Y bp (Zx coverage). Further analysis is discontinued.

Example Error: After QC, too little sequenced basepairs remain

If after cleaning reads, a sample has failed to meet the minimum number of sequenced basepairs, the sample will be excluded from further analysis. You can adjust this minimum read count using the --min_basepairs parameter.

Example Text from <SAMPLE_NAME>-low-sequence-depth-error.txt <SAMPLE_NAME> FASTQ(s) contain X total basepairs. This does not exceed the required minimum Y bp. Further analysis is discontinued.

Step 3 - Assembler

The assembler module uses a variety of assembly tools to create an assembly of Illumina and Oxford Nanopore reads. The tools used are:

ToolDescription
DragonflyeAssembly of Oxford Nanopore reads, as well as hybrid assembly with short-read polishing
ShovillAssembly of Illumina paired-end reads
Shovill-SEAssembly of Illumina single-end reads
UnicyclerHybrid assembly, using short-reads first then long-reads

Summary statistics for each assembly are generated using assembly-scan.

Prefer --short_polish over --hybrid with recent ONT sequencing

Using Unicycler (--hybrid) to create a hybrid assembly works great when you have low-coverage noisy long-reads. However, if you are using recent ONT sequencing, you likely have high-coverage and using the --short_polish method is going to yield better results (and be faster!) than --hybrid.

Failed Quality Checks

FilenameDescription
-assembly-error.txtSample failed assembly checks and excluded from further analysis
Poor samples are excluded to prevent downstream failures

Samples that fail any of the QC checks will be excluded from further analysis. Those samples will generate a *-error.txt file with the error message. Excluding these samples prevents downstream failures that cause the whole workflow to fail.

Example Error: Assembled Successfully, but 0 Contigs

If a sample assembles successfully, but 0 contigs are formed, the sample will be excluded from further analysis.

Example Text from <SAMPLE_NAME>-assembly-error.txt <SAMPLE_NAME> assembled successfully, but 0 contigs were formed. Please investigate <SAMPLE_NAME> to determine a cause (e.g. metagenomic, contaminants, etc...) for this outcome. Further assembly-based analysis of <SAMPLE_NAME> will be discontinued.

Example Error: Assembled successfully, but poor assembly size

If your sample assembles successfully, but the assembly size is less than the minimum allowed genome size, the sample will be excluded from further analysis. You can adjust this minimum size using the --min_genome_size parameter.

Example Text from <SAMPLE_NAME>-assembly-error.txt <SAMPLE_NAME> assembled size (000 bp) is less than the minimum allowed genome size (000 bp). If this is unexpected, please investigate <SAMPLE_NAME> to determine a cause (e.g. metagenomic, contaminants, etc...) for the poor assembly. Otherwise, adjust the --min_genome_size parameter to fit your need. Further assembly based analysis of <SAMPLE_NAME> will be discontinued.

Step 4 - Annotator

The annotator step uses either Prokka (default) or Bakta (via --use_bakta) to annotate assembled contigs with functional information including genes, proteins, rRNA, tRNA, and other genomic features.

Step 5 - Sketcher

The sketcher module uses Mash and Sourmash to create sketches and query RefSeq and GTDB.

Step 6 - Sequence Typing

The mlst step uses mlst to scan assemblies against PubMLST typing schemes and determine the sequence type.

Step 7 - Antibiotic Resistance

The amrfinderplus step uses AMRFinder+ to identify antimicrobial resistance genes and point mutations from both assembled contigs and annotated protein sequences.

Step 8 - Merlin

The merlin step automatically selects and runs species-specific typing tools based on Mash distance results from the sketcher step. Enable with --ask_merlin. See the Pathogen-Specific Analysis output section below for the full list of supported organisms and tools.

Usage

Bactopia CLI:

bactopia \
--input samples.csv \
--outdir results/

Nextflow:

nextflow run bactopia/bactopia \
--input samples.csv \
--outdir results/

Outputs

Expected Output Files

<BACTOPIA_DIR>
├── <SAMPLE_NAME>
│ ├── main
│ │ ├── annotator
│ │ │ └── prokka
│ │ │ ├── <SAMPLE_NAME>-blastdb.tar.gz
│ │ │ ├── <SAMPLE_NAME>.faa.gz
│ │ │ ├── <SAMPLE_NAME>.ffn.gz
│ │ │ ├── <SAMPLE_NAME>.fna.gz
│ │ │ ├── <SAMPLE_NAME>.fsa.gz
│ │ │ ├── <SAMPLE_NAME>.gbk.gz
│ │ │ ├── <SAMPLE_NAME>.gff.gz
│ │ │ ├── <SAMPLE_NAME>.sqn.gz
│ │ │ ├── <SAMPLE_NAME>.tbl.gz
│ │ │ ├── <SAMPLE_NAME>.tsv
│ │ │ ├── <SAMPLE_NAME>.txt
│ │ │ └── logs
│ │ │ ├── <SAMPLE_NAME>.err
│ │ │ ├── <SAMPLE_NAME>.log
│ │ │ ├── nf.command.{begin,err,log,out,run,sh,trace}
│ │ │ └── versions.yml
│ │ ├── assembler
│ │ │ ├── <SAMPLE_NAME>.fna.gz
│ │ │ ├── <SAMPLE_NAME>.tsv
│ │ │ ├── logs
│ │ │ │ ├── nf.command.{begin,err,log,out,run,sh,trace}
│ │ │ │ ├── shovill-se.log
│ │ │ │ └── versions.yml
│ │ │ └── supplemental
│ │ │ └── shovill.corrections
│ │ ├── gather
│ │ │ ├── <SAMPLE_NAME>-meta.tsv
│ │ │ └── logs
│ │ │ ├── nf.command.{begin,err,log,out,run,sh,trace}
│ │ │ └── versions.yml
│ │ ├── qc
│ │ │ ├── <SAMPLE_NAME>_SE.fastq.gz
│ │ │ ├── logs
│ │ │ │ ├── <SAMPLE_NAME>-fastp.log
│ │ │ │ ├── nf.command.{begin,err,log,out,run,sh,trace}
│ │ │ │ └── versions.yml
│ │ │ └── supplemental
│ │ │ ├── <SAMPLE_NAME>.fastp.html
│ │ │ ├── <SAMPLE_NAME>.fastp.json
│ │ │ ├── <SAMPLE_NAME>_SE-final.json
│ │ │ ├── <SAMPLE_NAME>_SE-final_fastqc.html
│ │ │ ├── <SAMPLE_NAME>_SE-final_fastqc.zip
│ │ │ ├── <SAMPLE_NAME>_SE-original.json
│ │ │ ├── <SAMPLE_NAME>_SE-original_fastqc.html
│ │ │ └── <SAMPLE_NAME>_SE-original_fastqc.zip
│ │ └── sketcher
│ │ ├── <SAMPLE_NAME>-k21.msh
│ │ ├── <SAMPLE_NAME>-k31.msh
│ │ ├── <SAMPLE_NAME>-mash-refseq88-k21.txt
│ │ ├── <SAMPLE_NAME>-sourmash-gtdb-rs207-k31.txt
│ │ ├── <SAMPLE_NAME>.sig
│ │ └── logs
│ │ ├── nf.command.{begin,err,log,out,run,sh,trace}
│ │ └── versions.yml
│ └── tools
│ ├── amrfinderplus
│ │ ├── <SAMPLE_NAME>.tsv
│ │ └── logs
│ │ ├── nf.command.{begin,err,log,out,run,sh,trace}
│ │ └── versions.yml
│ └── mlst
│ ├── <SAMPLE_NAME>.tsv
│ └── logs
│ ├── nf.command.{begin,err,log,out,run,sh,trace}
│ └── versions.yml
└── bactopia-runs
└── bactopia-<TIMESTAMP>
├── merged-results
│ ├── amrfinderplus.tsv
│ ├── assembly-scan.tsv
│ ├── logs
│ │ ├── amrfinderplus-concat
│ │ │ ├── nf.command.{begin,err,log,out,run,sh,trace}
│ │ │ └── versions.yml
│ │ ├── assembly-scan-concat
│ │ │ ├── nf.command.{begin,err,log,out,run,sh,trace}
│ │ │ └── versions.yml
│ │ ├── meta-concat
│ │ │ ├── nf.command.{begin,err,log,out,run,sh,trace}
│ │ │ └── versions.yml
│ │ └── mlst-concat
│ │ ├── nf.command.{begin,err,log,out,run,sh,trace}
│ │ └── versions.yml
│ ├── meta.tsv
│ └── mlst.tsv
└── nf-reports
├── bactopia-dag.dot
├── bactopia-report.html
└── bactopia-timeline.html

Quality Control

FileDescription
supplemental/*_fastqc.*FastQC quality control reports for raw and cleaned reads
supplemental/*-NanoPlot.*NanoPlot reports for Nanopore reads
supplemental/*.fastp.*Fastp quality reports (when applicable)
supplemental/*_original.jsonQuality metrics for original reads
supplemental/*_final.jsonQuality metrics for final reads

Assembly

FileDescription
*.fastaAssembled genome sequences
assembly-stats.tsvAssembly quality metrics
merged-assembly-stats.tsvConsolidated assembly statistics

Annotation

note

Output format depends on chosen annotation tool (Bakta or Prokka)

FileDescription
*.gff.gzGenome annotation in GFF3 format (compressed)
*.gbk.gzGenome annotation in GenBank format (compressed)
*.faa.gzProtein sequences (compressed)
*.fna.gzNucleotide sequences from annotation (compressed)
*.ffn.gzFeature nucleotide sequences (compressed)
annotation.tsvAnnotation summary tables
blastdb.*BLAST database created from annotation

Typing

FileDescription
mlst.tsvMLST sequence type results
merged-mlst.tsvConsolidated MLST results

Antimicrobial Resistance

FileDescription
amrfinderplus.tsvAMR gene detection results
amrfinderplus.mutation.tsvAMR point mutation results
merged-amrfinderplus.tsvConsolidated AMR results

Comparative Analysis

FileDescription
*-k21.mshMash sketch files (k=21)
*-k31.mshMash sketch files (k=31)
*-mash-refseq88-*.txtMash screening results against RefSeq
*.sigSourmash signatures
sourmash-*.txtSourmash classification results

Pathogen-Specific Analysis

note

Only created if --ask_merlin is enabled

FileDescription
merlin/clermontyping/*E. coli phylogroup typing
merlin/ectyper/*Enterotoxigenic E. coli typing
merlin/shigatyper/*Shigella serotype prediction
merlin/shigapass/*Shigella passive surveillance
merlin/shigeifinder/*Shigella and EIEC detection
merlin/stecfinder/*STEC detection and typing
merlin/emmtyper/*S. pyogenes emm typing
merlin/hicap/*H. influenzae capsular typing
merlin/hpsuissero/*H. parasuis serotyping
merlin/kleborate/*Klebsiella species typing
merlin/staphtyper/*S. aureus spa typing
merlin/agrvate/*S. aureus agr typing
merlin/sccmec/*S. aureus SCCmec typing

Merged Results

note

Run-level aggregated results from all samples

FileDescription
samplesheet.tsvSample metadata and quality metrics

Audit Trail

Below are files that can assist you in understanding which parameters and program versions were used.

Logs

Each process that is executed will have a folder named logs. In this folder are helpful files for you to review if the need ever arises.

ExtensionDescription
.beginAn empty file used to designate the process started
.errContains STDERR outputs from the process
.logContains both STDERR and STDOUT outputs from the process
.outContains STDOUT outputs from the process
.runThe script Nextflow uses to stage/unstage files and queue processes based on given profile
.shThe script executed by bash for the process
.traceThe Nextflow trace report for the process
versions.ymlA YAML formatted file with program versions

Nextflow Reports

These Nextflow reports provide great a great summary of your run. These can be used to optimize resource usage and estimate expected costs if using cloud platforms.

FilenameDescription
bactopia-dag.dotThe Nextflow DAG visualization
bactopia-report.htmlThe Nextflow Execution Report
bactopia-timeline.htmlThe Nextflow Timeline Report
bactopia-trace.txtThe Nextflow Trace report

Parameters

Required Parameters

The following parameters are how you will provide either local or remote samples to be processed by Bactopia.

ParameterTypeDefaultDescription
--samplesstringA FOFN (via bactopia prepare) with sample names and paths to FASTQ/FASTAs to process
--r1stringFirst set of compressed (gzip) Illumina paired-end FASTQ reads (requires --r2 and --sample)
--r2stringSecond set of compressed (gzip) Illumina paired-end FASTQ reads (requires --r1 and --sample)
--sestringCompressed (gzip) Illumina single-end FASTQ reads (requires --sample)
--ontstringCompressed (gzip) Oxford Nanopore FASTQ reads (requires --sample)
--hybridbooleanfalseCreate hybrid assembly using Unicycler. (requires --r1, --r2, --ont and --sample)
--short_polishbooleanfalseCreate hybrid assembly from long-read assembly and short read polishing. (requires --r1, --r2, --ont and --sample)
--samplestringSample name to use for the input sequences
--accessionsstringA file containing ENA/SRA Experiment accessions or NCBI Assembly accessions to processed
--accessionstringSample name to use for the input sequences
--assemblystringA assembled genome in compressed FASTA format. (requires --sample)
--check_samplesbooleanfalseValidate the input FOFN provided by --samples
Dataset Parameters

Define where the pipeline should find input data and save output data.

ParameterTypeDefaultDescription
--speciesstringName of species for species-specific dataset to use
--ask_merlinbooleanAsk Merlin to execute species specific Bactopia tools based on Mash distances
--coverageinteger100Reduce samples to a given coverage, requires a genome size
--genome_sizeinteger0Expected genome size (bp) for all samples, required for read error correction and read subsampling
--use_baktabooleanUse Bakta for annotation, instead of Prokka
Optional Parameters

These optional parameters can be useful in certain settings.

ParameterTypeDefaultDescription
--outdirstringbactopiaBase directory to write results to
Nextflow Profile Parameters

Parameters to fine-tune your Nextflow setup.

ParameterTypeDefaultDescription
--datasets_cachestring<HOME>/.bactopia/datasetsDirectory where downloaded datasets should be stored.
Helpful Parameters

Uncommonly used parameters that might be useful.

ParameterTypeDefaultDescription
--wfstringbactopiaSpecify which workflow or Bactopia Tool to execute
--list_wfsbooleanList the available workflows and Bactopia Tools to use with '--wf'
--help_allbooleanAn alias for --help --show_hidden_params
--versionbooleanDisplay version text.

Composition

This workflow uses the following subworkflows:

  • amrfinderplus - Find antimicrobial resistance genes and point mutations.
  • bactopia_assembler - Assemble bacterial genomes using automated assembler selection.
  • bactopia_datasets - Download and provide pre-compiled datasets required by Bactopia.
  • bactopia_gather - Search, validate, gather, and standardize input samples.
  • bactopia_qc - Perform comprehensive quality control on sequencing reads.
  • bactopia_sketcher - Create genomic sketches and perform rapid taxonomic classification.
  • bakta - Rapid bacterial genome annotation.
  • merlin - MinER assisted species-specific bactopia tool seLectIoN.
  • mlst - Determine multilocus sequence types (MLST) from bacterial assemblies.
  • prokka - Annotate bacterial genomes with functional information.

Source

View source on GitHub