KneadData
repository·master·Indexed 41 days ago
https://github.com/biobakery/kneaddataA bioinformatics tool for quality control of metagenomic and metatranscriptomic sequencing data. It specializes in the in silico separation of microbial reads from host or other contaminant DNA (such as human, mouse, dog, or cat genomes) and ribosomal RNA filtering using Bowtie2 or BMTagger.
What's inside KneadData
- KneadData is a quality control tool for metagenomic and metatranscriptomic sequencing data (e.g., microbiome experiments). Its primary function is the in silico separation of bacterial reads from 'contaminant' reads, such as host DNA (e.g., human, mouse, dog, cat), bacterial 16S sequences, or other user-defined sources. It can also be used for general filtering tasks, such as separating human and non-human reads in human sequencing experiments.
Install KneadData from source
masterYou can install KneadData from a cloned repository:
- Clone the repository:
$ git clone https://github.com/biobakery/kneaddata.git - Navigate to the directory:
$ cd kneaddata - Run the installation:
$ python setup.py install
Options:
- Bypass dependencies: Add
--bypass-dependencies-installto skip Trimmomatic and Bowtie2 installation. - User-level install: Add
--userif you lack write permissions to/usr/lib/. Remember to add$HOME/.local/bin/to your$PATHif necessary.
$ git clone https://github.com/biobakery/kneaddata.git $ cd kneaddata $ python setup.py install- Clone the repository:
Install KneadData via pip
masterThe recommended way to install KneadData is using
pip. This method automatically installs Trimmomatic and Bowtie2.- Standard install:
pip install kneaddata - Bypass dependency installation: Use
--install-option='--bypass-dependencies-install'if you want to skip the automatic installation of Trimmomatic and Bowtie2. - User-level install: If you lack write permissions to
/usr/lib/, use the--userflag. This installs the package into$HOME/.local.
Important: If you use
--user, you may need to manually add$HOME/.local/bin/to your$PATHif you encounter the errorkneaddata: command not found.$ pip install kneaddata # Or for user-level installation $ pip install --user kneaddata- Standard install:
Download the indexed human reference database
masterYou can use the
kneaddata_databaseutility to download pre-indexed common databases. To download the indexed human reference database, use the--downloadflag withhumanand specify the alignment tool (e.g.,bowtie2).Replace
$DIRwith the full path to the directory where you want to store the database.$ kneaddata_database --download human bowtie2 $DIRCreate a Bowtie2 database from a FASTA file
masterTo create a custom Bowtie2 database, use the
bowtie2-buildcommand. This requires a reference FASTA file and a name for the database.Note for SILVA ribosomal_RNA: If you are creating a database from SILVA ribosomal RNA sequences, you must first run the
modify_RNA_to_DNA.pyscript to convert 'U's to 'T's in the FASTA sequences before runningbowtie2-build.# Standard Bowtie2 build $ bowtie2-build <reference> <db-name> # Required preprocessing for SILVA ribosomal_RNA $ python -u modify_RNA_to_DNA.py input.fasta output.fa $ bowtie2-build output.fa <db-name>Download KneadData Bowtie2 Databases
masterKneadData provides pre-built Bowtie2 databases for contamination removal and ribosomal RNA filtering. You can download the following versions:
- human_genome (v0.1)
- human_transcriptome (v0.1)
- mouse_C57BL (v0.1)
- ribosomal_RNA (v0.2)
These databases are typically used to identify and filter out host or unwanted sequences from sequencing data.
Download KneadData reference databases
masterUse the
kneaddata_databasecommand to download pre-configured reference databases. Replace$DIRwith the full path to your desired storage directory.Available Databases:
- Human Genome (Bowtie2):
kneaddata_database --download human_genome bowtie2 $DIR - Human Transcriptome (Bowtie2):
kneaddata_database --download human_transcriptome bowtie2 $DIR - Ribosomal RNA (SILVA, Bowtie2):
kneaddata_database --download ribosomal_RNA bowtie2 $DIR - Mouse C57BL (Bowtie2):
kneaddata_database --download mouse_C57BL bowtie2 $DIR - Dog Genome (German Shepherd, Bowtie2):
kneaddata_database --download dog_genome bowtie2 $DIR - Dog Genome (Domestic, via wget):
wget https://huttenhower.sph.harvard.edu/kneadData_databases/dog_genome.tar.gz - Cat Genome (Bowtie2):
kneaddata_database --download cat_genome bowtie2 $DIR
Using BMTagger: If you prefer BMTagger over Bowtie2, download the BMTagger version of the human genome:
kneaddata_database --download human_genome bmtagger $DIR# Example: Downloading the human genome for Bowtie2 $ kneaddata_database --download human_genome bowtie2 /path/to/your/database_dir- Human Genome (Bowtie2):
Use Trimmomatic adapters for Illumina trimming
masterKneadData utilizes adapters provided by Trimmomatic to perform adapter trimming on Illumina sequencing data. These adapters are required for the trimming step of the KneadData pipeline to ensure high-quality reads by removing known adapter sequences.Use --bypass-trim and handle naming requirements
masterWhen using the
--bypass-trimflag, KneadData expects input files to follow its post-trim naming convention (e.g.,*.trimmed.fastq). If you provide a standardinput.fastq, the run may crash with an unclear error.Workaround: Rename your input file to include the
.trimmedsuffix before running KneadData.mv input.fastq input.trimmed.fastqRun a KneadData demo
masterYou can perform a test run using the provided demo files. This example uses an unpaired FASTQ file and a demo database to generate output files including trimmed reads, contaminant reads, and logs.
$ kneaddata --unpaired examples/demo.fastq --reference-db examples/demo_db --output kneaddata_demo_outputGenerate ribosomal_RNA Bowtie2 database
masterTo generate a
ribosomal_RNABowtie2 database, you must first convert the RNA fasta to DNA format using the provided script, then proceed with synthetic read generation and index building:- Convert RNA to DNA using
modify_RNA_to_DNA.py. - Extract a subset of the fasta.
- Generate synthetic reads using
art_illumina. - Build the Bowtie2 index.
# 1. Convert RNA to DNA $ python -u modify_RNA_to_DNA.py ribosomal_RNA_initial.fasta ribosomal_RNA.fasta # 2. Extract genome subset $ bowtie2-inspect /ribosomal_RNA | head -n 1000 > ribosomal_RNA.fasta # 3. Generate synthetic reads $ ./art_illumina -i ribosomal_RNA.fasta -l 100 -o ribosomal_RNA_synthetic_reads -sam -ss HS20 -f 0.3 --id ribosomal_RNA # 4. Build Bowtie2 database $ bowtie2-build ribosomal_RNA.fasta ribosomal_RNA- Convert RNA to DNA using
Generate Bowtie2 databases for human or mouse genomes
masterTo manually generate Bowtie2 databases and synthetic reads for
human_genome,human_transcriptome, ormouse_C57BL, follow these steps usingbowtie2-inspect,art_illumina, andbowtie2-build:- Extract a subset of the genome fasta.
- Generate synthetic reads using
art_illumina. - Build the Bowtie2 index.
# 1. Extract genome subset $ bowtie2-inspect /genome_demo | head -n 1000 > genome_demo.fasta # 2. Generate synthetic reads $ ./art_illumina -i genome_demo.fasta -l 100 -o genome_demo_synthetic_reads -sam -ss HS20 -f 0.3 --id genome_demo # 3. Build Bowtie2 database $ bowtie2-build genome_demo.fasta genome_demo