KneadData

repository·master·Indexed 41 days ago

https://github.com/biobakery/kneaddata

A 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.

Tokens
5.9K
Snippets
17
Records
22
Agent score
99%

What's inside KneadData

  1. Overview of KneadData

    master
    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.
  2. Install KneadData from source

    master

    You can install KneadData from a cloned repository:

    1. Clone the repository: $ git clone https://github.com/biobakery/kneaddata.git
    2. Navigate to the directory: $ cd kneaddata
    3. Run the installation: $ python setup.py install

    Options:

    • Bypass dependencies: Add --bypass-dependencies-install to skip Trimmomatic and Bowtie2 installation.
    • User-level install: Add --user if you lack write permissions to /usr/lib/. Remember to add $HOME/.local/bin/ to your $PATH if necessary.
    $ git clone https://github.com/biobakery/kneaddata.git
    $ cd kneaddata
    $ python setup.py install
  3. Install KneadData via pip

    master

    The 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 --user flag. This installs the package into $HOME/.local.

    Important: If you use --user, you may need to manually add $HOME/.local/bin/ to your $PATH if you encounter the error kneaddata: command not found.

    $ pip install kneaddata
    # Or for user-level installation
    $ pip install --user kneaddata
  4. Download the indexed human reference database

    master

    You can use the kneaddata_database utility to download pre-indexed common databases. To download the indexed human reference database, use the --download flag with human and specify the alignment tool (e.g., bowtie2).

    Replace $DIR with the full path to the directory where you want to store the database.

    $ kneaddata_database --download human bowtie2 $DIR
  5. Create a Bowtie2 database from a FASTA file

    master

    To create a custom Bowtie2 database, use the bowtie2-build command. 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.py script to convert 'U's to 'T's in the FASTA sequences before running bowtie2-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>
  6. Download KneadData Bowtie2 Databases

    master

    KneadData 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.

  7. Download KneadData reference databases

    master

    Use the kneaddata_database command to download pre-configured reference databases. Replace $DIR with 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
  8. Use --bypass-trim and handle naming requirements

    master

    When using the --bypass-trim flag, KneadData expects input files to follow its post-trim naming convention (e.g., *.trimmed.fastq). If you provide a standard input.fastq, the run may crash with an unclear error.

    Workaround: Rename your input file to include the .trimmed suffix before running KneadData.

    mv input.fastq input.trimmed.fastq
  9. Run a KneadData demo

    master

    You 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_output
  10. Generate ribosomal_RNA Bowtie2 database

    master

    To generate a ribosomal_RNA Bowtie2 database, you must first convert the RNA fasta to DNA format using the provided script, then proceed with synthetic read generation and index building:

    1. Convert RNA to DNA using modify_RNA_to_DNA.py.
    2. Extract a subset of the fasta.
    3. Generate synthetic reads using art_illumina.
    4. 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
  11. Generate Bowtie2 databases for human or mouse genomes

    master

    To manually generate Bowtie2 databases and synthetic reads for human_genome, human_transcriptome, or mouse_C57BL, follow these steps using bowtie2-inspect, art_illumina, and bowtie2-build:

    1. Extract a subset of the genome fasta.
    2. Generate synthetic reads using art_illumina.
    3. 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