Skip to content

Bracken (Bayesian Reestimation of Abundance with KrakEN) is a highly accurate statistical method that computes the abundance of species in DNA sequences from a metagenomics sample.

License

Notifications You must be signed in to change notification settings

MaryoHg/Bracken

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bracken abundance estimation

For Bracken news, updates, and instructions: ccb.jhu.edu/software/bracken/

Bracken's peer-reviewed paper (published Jan 2, 2017): https://peerj.com/articles/cs-104/

Installation

To install simply copy or link the scripts in src/ to a folder on your PATH.

Running Bracken

If you run Kraken using one of the pre-built MiniKraken databases you can find corresponding Bracken databases here.

Step 1: Classify all reads using Kraken and generate a Kraken report file

Kraken can be downloaded from here: http://ccb.jhu.edu/software/kraken/

Three steps are necessary to set up Kraken abundance estimation. It is assumed that ${KRAKEN_DB} is the path to a built Kraken database, and all sequences are as .fna files in the ${KRAKEN_DB}/library directory.

Step 2: Produce a kmer distribution file for your Kraken database

Step 2a: Search all library input sequences against the database

kraken --db=${KRAKEN_DB} --fasta-input --threads=10 <( find -L library -name "*.fna" -o -name "*.fa" -o -name "*.fasta" -exec cat {} + )  > database.kraken

Step 2b: Compute classifications for each perfect read from one of the input sequences

With ${READ_LENGTH} = 75:

perl count-kmer-abundances.pl --db=${KRAKEN_DB} --read-length=75 database.kraken  > database75mers.kraken_cnts

Set ${READ_LENGTH} to whatever is the most likely perfect read length of your data. E.g., if you are using 100 bp reads, set it to 100.

Step 3: Generate the kmer distribution file

The kmer distribution file is generated using the following command line:

python generate_kmer_distribution.py -i database75mers.kraken_cnts -o KMER_DISTR.TXT

Step 4: Estimate abundance

Given the expected kmer distribution for genomes in a kraken database along with a kraken report file, the number of reads belonging to each species (or genus) is estimated using the estimate_abundance.py file, run with the following command line:

python estimate_abundance.py -i <KRAKEN.REPORT> -k <KMER_DISTR.TXT> -l <CLASSIFICATON_LEVEL> -t <THRESHOLD> -o <OUTPUT_FILE.TXT>

The following required parameters must be specified:

  • <KRAKEN.REPORT> - the kraken report generated for a given dataset
  • <KMER_DISTR.TXT> - the file generated by generate_kmer_distribution.py
  • <OUTPUT_FILE.TXT> - the desired name of the output file to be generated by the code

The following optional parameters may be specified:

  • <CLASSIFICATION_LEVEL> - Default = 'S'. This specifies that abundance estimation will calculate estimated reads for each species. Other possible options are K (kingdom level), P (phylum), C (class), O (order), F (family), and G (genus).
  • <THRESHOLD> - Default = 10. For species classification, any species with <= 10 (or otherwise specified) reads will not receive any additional reads from higher taxonomy levels when distributing reads for abundance estimation. If another classification level is specified, thresholding will occur at that level.

Example abundance estimation

The following sample input and output files are included in the sample_data/ folder: sample_test.report - Kraken report file generated from the kraken-report command. sample_kmer_distr_75mers.txt - example kmer distribution file generated by generate_kmer_distribution.py sample_output_species_abundance.txt - Bracken species abundance estimation for sample_test.report sample_output_bracken.report - Kraken report style file with all reads redistributed to the species level

Due to size constraints, the following files are not included in the sample_data/ folder: sample_test.kraken - Kraken output file used to generate the Kraken report file database.kraken - Initial Kraken classification of every genome database75mers.kraken_cnts - Counting of kmer abundances

The following commands were used to generate each individual file:

  1.  kraken --db${KRAKEN_DB} --threads=10 sample.fa > sample_test.kraken
     kraken-report --db=${KRAKEN_DB} sample_test.kraken > sample_test.report 
    
  2.  kraken --db=${KRAKEN_DB} --fasta_input --threads=10 <( find -L library -name "*.fna" -o -name "*.fa" -o -name "*.fasta" -exec cat {} + ) > database.kraken 
     perl count-kmer-abubndances.pl --db=${KRAKEN_DB} --read-length=75 database.kraken > database75mers.kraken_cnts
    
  3.  python generate_kmer_distribution.py -i database75mers.kraken_cnts -o sample_kmer_distr_75mers.txt
    
  4.  python estimate_abundance.py -i sample_test.report -k sample_kmer_distr_75mers.txt -l S -t 10 -o sample_output_species_abundance.txt 
    

Copyright and licensing

Copyright (C) 2016 Jennifer Lu, [email protected]

Bracken is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the license, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/.

Author information

Jennifer Lu ([email protected], ccb.jhu.edu/people/jennifer.lu)

Florian Breitwieser ([email protected], ccb.jhu.edu/people/florian)

Last Updated On: 02/06/2017

About

Bracken (Bayesian Reestimation of Abundance with KrakEN) is a highly accurate statistical method that computes the abundance of species in DNA sequences from a metagenomics sample.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 76.4%
  • Perl 23.6%