omics.co.in logo omics.co.in

Chapter 6: Shotgun Metagenomics QC & Host DNA Decontamination

Tested Stacks: GATK 4.6.1 Samtools 1.21 Nextflow 24.10 Seurat v5.1 Python 3.12
Prerequisites: Basic Linux CLI & Sequencing Formats
📚 Chapter 6 of 13 0% Course Completed

Chapter 6: Shotgun Metagenomics QC & Host DNA Decontamination

Unlike amplicon sequencing which selectively amplifies bacterial 16S genes, Whole Metagenome Shotgun (WMS) sequences all extracted DNA. In clinical biopsies, saliva, or vaginal swabs, host DNA (human genome) can comprise 90–99% of total sequencing reads, leaving only a tiny fraction of genuine microbial data.

The Decontamination Workflow

Raw reads must be quality-trimmed and aligned against a reference host genome (e.g. GRCh38 or T2T-CHM13). Unmapped read pairs are extracted and passed forward as pure microbial reads, while host reads are discarded to protect patient genetic privacy.

1. Running kneaddata Pipeline

# Decontaminate paired-end human metagenomic reads
kneaddata \\
    --input sample_R1.fastq.gz \\
    --input sample_R2.fastq.gz \\
    --reference-db /ref/human_genome_bowtie2_index \\
    --output ./decontaminated_reads/ \\
    --threads 16 \\
    --fastqc fastqc \\
    --trimmomatic /opt/trimmomatic/

# Resulting files:
# sample_kneaddata_paired_1.fastq (Pure microbial R1)
# sample_kneaddata_paired_2.fastq (Pure microbial R2)

2. Manual Host Removal with Bowtie2 & Samtools

# Fast manual host alignment and extraction of unmapped pairs
bowtie2 -x /ref/grch38_index \\
        -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz \\
        --threads 16 --very-sensitive-local | \\
samtools fastq -@ 8 -f 12 -F 256 \\
        -1 microbial_R1.fastq.gz -2 microbial_R2.fastq.gz -
⚠️

Common Pitfalls & Troubleshooting Checklist

  • Java Heap Exhaustion (GATK / Picard): If processes terminate with java.lang.OutOfMemoryError, set your environment variable explicitly: export _JAVA_OPTIONS="-Xmx16g -Djava.io.tmpdir=/tmp".
  • Index Timestamp Mismatch: If tools complain that a BAM index is missing or out of date, regenerate with samtools index -@ 4 sample.bam.
  • Conda Channel Conflicts: Avoid ABI incompatibilities between bioconda and conda-forge by setting strict priority: conda config --set channel_priority strict.
  • Chromosome Naming Contamination: Always verify whether reference FASTA headers use chr1 or 1; divergent naming causes silent alignment drops.
Was this guide helpful to your research?
Help us maintain 100% accurate, peer-reviewed bioinformatics standards.
📝 Propose Edit on GitHub ↗