Help me build a metagenomic assembly and binning workflow: quality filtering, co‑assembly choices, bin refinement, contamination checks, and functional annotation.
Assistant
The user wants a metagenomic assembly and bining workflow.
This is a common bioinformatics task, but there are many choices to be made at each step.
I need to structure the response logically, following the pipeline steps requested:
Quality Filtering & Trimming
Assembly (including Co-assembly vs Individual)
Binning
Bin Refinement
Contamination Checks (Quality Assessment)
Functional Annotation
Step 1: Quality Filtering & Trimming
Input: Raw FASTQ files (Illumina is standard, perhaps mention long reads but keep it simple for now).
Recommendation: fastp is fast, all-in-one, and produces good reports. FastQC is essential for before/after checks.
Key parameters: Remove adapters, trim low-quality ends (Q<20 or Q<30), discard short reads (<50bp).
Step 2: Assembly
The Big Question: Individual assembly vs. Co-assembly.
Individual: Better for specific strain variation, time-series where community changes, avoids chimeras from similar species in different samples.
Co-assembly: Better coverage for low-abundance species, reconstructs more MAGs, but computationally expensive and prone to chimeras if samples are too distinct.
Hybrid: Assembly sample groups by similarity.
Tools: MEGAHIT (fast, good for complex), metaSPAdes (gold standard but RAM heavy), Flye (long reads).
Recommendation: MEGAHIT for large datasets/co-assembly, metaSPAdes for high-quality smaller sets.
Step 3: Read Mapping (Crucial intermediate step)
Need to map reads back to contigs to get coverage information for binning.
Tools: Bowtie2, BWA-mem, minimap2.
Output: BAM files (sorted/indexed).
Tool for depth: jgi_summarize_bam_contig_depths (from MetaBAT2 suite).
Step 4: Binning
Input: Contigs (FASTA) + Coverage (Depth file).
Tools: MetaBAT2, MaxBin2, CONCOCT.
Strategy: Run all of them.
Why?: Different algorithms use different signals (tetranucleotide frequency vs coverage). Combining them yields better results.
Step 5: Bin Refinement
Input: Bins from Step 4.
Tool: DAS Tool (Decontamination and Aggregation of Bins).
Function: Takes bins from MetaBAT2, MaxBin2, CONCOCT and creates a consensus set of "Refined Bins" (often higher quality/completeness).
Taxonomy: GTDB-Tk (Genome Taxonomy Database) is the current standard.
Gene Calling: Prodigal (Meta mode).
Functional Assignment:
KEGG: KofamScan (KOFAM).
CAZymes (Carbs): dbCAN2 (HMMER/DIAMOND/Hotpep).
General: DRAM (Distilled and Refined Annotation of Metabolism) - great summary.
AntiSMASH (Biosynthetic gene clusters).
Structure & Formatting
Use a step-by-step guide.
Provide specific command line examples (pseudo-code or basic flags).
Create a "Decision Matrix" for Co-assembly vs Individual.
Add a "Pro-Tips" section.
Reviewing the Content:
Did I miss anything? Human read removal (DeconRMS/bowtie2 mapping to human genome) is important for host-associated samples. I should mention it in QC.
Is the order right? QC -> Assembly -> Mapping -> Binning -> Refinement -> QA -> Annotation. Yes.
Tools selection: I should stick to the most widely used, open-source tools that play well together (e.g., the standard metawrap or atlas stack logic).
Refining the specific advice on Co-assembly:
Co-assembly is tricky. If sample A is soil from Brazil and sample B is soil from Canada, co-assembly might create chimeras. If they are replicates or time points from the same site, co-assembly is great. I need to emphasize sample similarity.
Refining Annotation:
DRAM is a really good wrapper for annotation. I should recommend it to simplify the user's life rather than telling them to run Prodigal then KofamScan then dbCAN manually.
Drafting the Response:
Start with a high-level flowchart.
Break down into 6 distinct phases.
Include code snippets.
End with a summary table of quality thresholds.
(Self-Correction during drafting): I shouldn't just list tools; I need to explain why and when to use specific parameters (e.g., --preservemer in megahit isn't usually needed, but --min-contig-len matters for binning usually 1000bp or 1500bp).
Let's write it out.
Building a robust metagenomic workflow requires balancing computational efficiency with biological accuracy. Below is a comprehensive, step-by-step guide to building a modern workflow, focusing on the critical decision points you mentioned.
This workflow assumes you are starting with Illumina short-read sequencing data.
Phase 1: Quality Control & Filtering
Before assembly, you must remove sequencing artifacts and host contamination.
1. Visualizing Raw Data
Tool:FastQC or MultiQC (aggregates reports).
Goal: Check for adapter contamination, low-quality tails, and GC content anomalies.
2. Trimming & Filtering
Tool:fastp (highly recommended for speed and all-in-one features) or Trimmomatic.
Key Parameters:
Detect and trim adapters automatically (--detect_adapter_for_pe).
Trim low-quality bases (e.g., Quality score < 20).
Crucial: Discard reads that become too short after trimming (e.g., < 50bp).
Binning groups contigs (fragments of DNA) into Metagenome-Assembled Genomes (MAGs) based on their sequence composition (k-mer frequencies) and abundance (coverage across samples).
1. Pre-processing: Coverage Calculation
You need to know how abundant each contig is in every sample.
Tool:Bowtie2 (map reads back to contigs) + jgi_summarize_bam_contig_depths (part of MetaBAT2 suite).
This generates a depth.txt file which is the input for binners.
2. The Binning Algorithm
Do not rely on a single binner. Use an ensemble approach.
MetaBAT2: Robust and standard.
MaxBin2: Good, but struggles with very high diversity.
VAMB: Uses deep learning; excellent for separating closely related strains.
Phase 4: Bin Refinement (The Critical Step)
Different binners produce different results. Refinement merges the best parts of these results to produce high-quality MAGs.
Tool: DAS Tool
It takes the bins from MetaBAT2, MaxBin2, and VAMB as input.
It scores contigs and consolidates them into a refined set of bins.
This usually results in a higher number of total high-quality bins than any single binner alone.
Once you have your refined bins, you must filter out garbage.
Tool: CheckM2 (Newer, faster version of CheckM1)
It uses a machine learning model trained on a vast array of genomes to estimate Completeness and Contamination.
Quality Thresholds (MIMAG Standards):
High Quality: >90% Complete, <5% Contamination.
Medium Quality (MQ): >50% Complete, <10% Contamination.
Tool: GUNC (Genome UNClutterer)
CheckM checks for general contamination, but GUNC specifically checks for chimerism (contigs from different species that got glued together). This is essential if you are looking at novel taxonomy.
Tool: RefineM (Optional)
If you have a bin with 15% contamination, you can use RefineM (or manual inspection in Anvi'o) to identify outlier contigs (based on GC content or tetranucleotide frequency) and remove them to rescue the bin.
Phase 6: Functional Annotation
Now that you have clean MAGs, what can they do?
1. Gene Prediction
Tool:Prodigal (in metagenomic mode run_Prodigal).
This identifies Open Reading Frames (ORFs) on your contigs.
2. Functional Assignment
DRAM (Distilled and Refined Annotation of Metabolism): One of the best current tools. It annotates against KEGG, Pfam, MEROPS, CAZyme (carbs), etc., and generates "Distillate" summary sheets that are human-readable.
eggNOG-mapper / COG: Fast functional annotation using orthology assignments.
KofamScan: Specifically for KEGG Orthology (KO) pathways.
3. Taxonomy
GTDB-Tk: The gold standard for taxonomic classification of MAGs based on the Genome Taxonomy Database.
Summary Workflow Pipeline
If you were to chain this into a pipeline, it would look like this:
Implementation Note:
If you prefer a managed environment, the ATLAS (by Metagenomics Lab) or nf-core/mag (Nextflow) pipelines implement exactly this logic. I recommend running those if you don't want to script the connections yourself, but understanding the steps above is vital for debugging.