• Stars
    star
    139
  • Rank 262,954 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created about 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Accurate metagenomic profiling && Fast large-scale sequence/genome searching

Kmer-based Metagenomic Classification and Profiling

KMCP: accurate metagenomic profiling of both prokaryotic and viral populations by pseudo-mapping

Citation

KMCP: accurate metagenomic profiling of both prokaryotic and viral populations by pseudo-mapping.
Wei Shen, Hongyan Xiang, Tianquan Huang, Hui Tang, Mingli Peng, Dachuan Cai, Peng Hu, Hong Ren.
Bioinformatics, btac845, https://doi.org/10.1093/bioinformatics/btac845

Table of contents

Documents

https://bioinf.shenwei.me/kmcp

What can we do?

1. Accurate metagenomic profiling

KMCP utilizes genome coverage information by splitting the reference genomes into chunks and stores k-mers in a modified and optimized COBS index for fast alignment-free sequence searching. KMCP combines k-mer similarity and genome coverage information to reduce the false positive rate of k-mer-based taxonomic classification and profiling methods.

The read mapping process in KMCP is referred to as pseudo-mapping, which is similar to but different from the lightweight algorithm in Sailfish (Patro et al., 2014), pseudoalignment in Kallisto (Bray et al., 2016), quasi-mapping in RapMap (Srivastava et al., 2016), and lightweight mapping in Salmon (Patro et al., 2017). All of these methods seek to elide the computation of base-to-base alignment using distinct strategies (Srivastava et al., 2016). In KMCP, each reference genome is pre-split into chunks of equal size, and the k-mers of a query, as a whole, are compared to each genome chunk to find all possible ones sharing a predefined proportion of k-mers with the query. Like quasi-mapping in RapMap, KMCP tracks the target and position for each query. However, the read position in KMCP is approximate and in a predefined resolution (the number of genome chunks).

Benchmarking results based on simulated and real data demonstrate that KMCP, despite a longer running time than some other methods, not only allows the accurate taxonomic profiling of prokaryotic and viral populations but also provides more confident pathogen detection in clinical samples of low depth.

Genome collections with custom taxonomy, e.g., GTDB uses its own taxonomy and MGV uses ICTV taxonomy, are also supported by generating NCBI-style taxdump files with taxonkit create-taxdump. You can even merge the GTDB taxonomy (for prokaryotic genomes from GTDB) and NCBI taxonomy (for genomes from NCBI).

2. Fast sequence search against large scales of genomic datasets

KMCP can be used for fast sequence search against large scales of genomic datasets as BIGSI and COBS do. We reimplemented and modified the Compact Bit-Sliced Signature index (COBS) algorithm, bringing a smaller index size and much faster searching speed (2x for genome search and 10x for short reads) faster than COBS (check the tutorial and benchmark). Also check the algorithm and data structure differences between KMCP and COBS.

3. Fast genome similarity estimation

KMCP can also be used for fast similarity estimation of assemblies/genomes against known reference genomes.

Genome sketching is a method of utilizing small and approximate summaries of genomic data for fast searching and comparison. Mash and Sourmash provide fast genome distance estimation using MinHash (Mash) or FracMinHash (Sourmash). KMCP supports multiple k-mer sketches (Minimizer, FracMinHash (previously named Scaled MinHash), and Closed Syncmers) for genome similarity estimation. And KMCP is 5x-7x faster than Mash/Sourmash (check the tutorial and benchmark).

Features

  • Easy to install
  • Easy to use
  • Building database is easy and fast
  • Fast searching speed (for sequence/genome search)
    • The index structure is modified from COBS, while KMCP is 2x-10x faster in sequence searching.
    • Automatically scales to exploit all available CPU cores.
    • Searching time is linearly related to the number of reference genomes (chunks).
  • Scalable searching. Searching results against multiple databases can be fast merged. This brings many benefits:
    • There's no need to re-built the database with newly added reference genomes.
    • The searching step can be parallelized with a computer cluster in which each computation node searches against a small database.
    • Computers with limited main memory can also utilize an extensive collection of reference genomes by building and searching against small databases..
  • Accurate taxonomic profiling
  • Flexible support of taxonomy database


Installation

Latest Version Github Releases Cross-platform Anaconda Cloud

Download executable binaries, or install using conda:

conda install -c bioconda kmcp

SIMD extensions including AVX512, AVX2, SSE2 are sequentially detected and used in two packages for better searching performance.

  • pand, for accelerating searching on databases constructed with multiple hash functions.
  • pospop, for batch counting matched k-mers in bloom filters.

ARM architecture is supported, but kmcp search would be slower.

Commands

Subcommand Function
compute Generate k-mers (sketch) from FASTA/Q sequences
index Construct a database from k-mer files
search Search sequences against a database
merge Merge search results from multiple databases
profile Generate the taxonomic profile from search results
utils split-genomes Split genomes into chunks
utils unik-info Print information of .unik files
utils index-info Print information of index files
utils index-density Plot the element density of bloom filters for an index file
utils ref-info Print information of reference chunks in a database
utils cov2simi Convert k-mer coverage to sequence similarity
utils query-fpr Compute the false positive rate of a query
utils filter Filter search results and find species/assembly-specific queries
utils merge-regions Merge species/assembly-specific regions

Quickstart

# compute k-mers
kmcp compute -k 21 --split-number 10 --split-overlap 150 \
    --in-dir genomes/ --out-dir genomes-k21-n10

# index k-mers
kmcp index --false-positive-rate 0.1 --num-hash 1 \
    --in-dir genomes-k21-n10/ --out-dir genomes.kmcp

# delete temporary files
# rm -rf genomes-k21-n10/

# search    
kmcp search --db-dir genomes.kmcp/ test.fa.gz --out-file [email protected]

# merge search results against multiple databases
kmcp merge -o search.kmcp.tsv.gz search.kmcp@*.kmcp.tsv.gz

# profile and binning
kmcp profile search.kmcp.tsv.gz \
    --taxid-map        taxid.map \
    --taxdump          taxdump/ \
    --out-file         search.tsv.gz.k.profile \
    --metaphlan-report search.tsv.gz.m.profile \
    --cami-report      search.tsv.gz.c.profile \
    --binning-result   search.tsv.gz.binning.gz

Next:

KMCP vs COBS

We reimplemented and modified the Compact Bit-Sliced Signature index (COBS) algorithm, bringing a smaller index size and much faster searching speed (2x for genome search and 10x for short reads) faster than COBS.

The differences between KMCP and COBS

Category Item COBS KMCP Comment
Algorithm K-mer hashing xxhash ntHash1 xxHash is a general-purpose hashing function while ntHash is a recursive hash function for DNA/RNA
Bloom filter hashing xxhash Using k-mer hash values Avoid hash computation
Multiple-hash functions xxhash with different seeds Generating multiple values from a single one Avoid hash computation
Single-hash function Same as multiple-hash functions Separated workflow Reducing loops
AND step Serial bitwise AND Vectorised bitwise AND Bitwise AND for >1 hash functions
PLUS step Serial bit-unpacking Vectorised positional popcount with pospop Counting from bit-packed data
Index structure Size of blocks / Using extra thresholds to split the last block with the most k-mers Uneven genome size distribution would make bloom filters of the last block extremely huge
Index files Concatenated Independent
Index loading mmap, loading complete index into RAM mmap, loading complete index into RAM, seek Index loading modes
Input/output Input files FASTA/Q, McCortex, text FASTA/Q
Output Target and matched k-mers Target, matched k-mers, query FPR, etc.

Support

Please open an issue to report bugs, propose new functions, or ask for help.

License

MIT License

Acknowledgments

  • Zhi-Luo Deng (Helmholtz Centre for Infection Research, Germany) gave a lot of valuable advice on metagenomic profiling and benchmarking.
  • Robert Clausecker (Zuse Institute Berlin, Germany) wrote the high-performance vectorized positional popcount package (pospop) during my development of KMCP, which greatly accelerated the bit-matrix searching.

More Repositories

1

seqkit

A cross-platform and ultrafast toolkit for FASTA/Q file manipulation
Go
1,066
star
2

csvtk

A cross-platform, efficient and practical CSV/TSV toolkit in Golang
Go
882
star
3

awesome

Awesome resources on Bioinformatics, data science, machine learning, programming language (Python, Golang, R, Perl) and miscellaneous stuff.
568
star
4

taxonkit

A Practical and Efficient NCBI Taxonomy Toolkit, also supports creating NCBI-style taxdump files for custom taxonomies
Go
256
star
5

brename

A practical cross-platform command-line tool for safely batch renaming files/directories via regular expression
Go
224
star
6

LexicMap

LexicMap: efficient sequence alignment against millions of prokaryotic genomes
Go
96
star
7

bio_scripts

Practical, reusable scripts for bioinformatics
Perl
90
star
8

bio

A lightweight and high-performance bioinformatics package in Golang
Go
83
star
9

unikmer

Toolkit for k-mer with taxonomic information
Go
53
star
10

ClipboardTextJoiner

Monitoring system clipboard change and joining multi-line text. It's very useful when copying multi-line text from PDF files.
Perl
47
star
11

go4bio

Golang for Bioinformatics
31
star
12

gtdb-taxdump

GTDB taxonomy taxdump files with trackable TaxIds
R
28
star
13

easy_qsub

Easily submitting multiple PBS jobs or running local jobs in parallel. Multiple input files supported.
Python
27
star
14

countminsketch

An implementation of Count-Min Sketch in Golang
Go
24
star
15

taxid-changelog

NCBI taxonomic identifier (taxid) changelog, including taxids deletion, new adding, merge, reuse, and rank/name changes.
R
19
star
16

bwt

Burrows-Wheeler Transform and FM-index in golang
Go
18
star
17

cnote

A platform independent command line note app
Go
17
star
18

gtaxon

gTaxon - a fast cross-platform NCBI taxonomy data querying (gi2taxid, taxid2taxon, name2taxid, LCA) tool, with cmd client and REST API server for both local and remote server.
Go
15
star
19

easy_sbatch

easy_sbatch - Batch submitting Slurm jobs with script templates
Python
14
star
20

ncbi_acc2gtdb_acc

Mapping NCBI Genbank accession to GTDB accession
14
star
21

strobemers

A Go implementation of the strobemers (https://github.com/ksahlin/strobemers)
Go
14
star
22

ictv-taxdump

NCBI-style taxdump files for International Committee on Taxonomy of Viruses (ICTV)
12
star
23

crun

Run workflow mixed with concurrent and sequential jobs. Please use https://github.com/shenwei356/rush
Go
10
star
24

breader

breader (Buffered File Reader), asynchronous parsing and pre-processing while reading file. Safe cancellation is also supported.
Go
9
star
25

pinyin

收集汉字,结合汉语拼音来取名
Python
8
star
26

lexichash

LexicHash in Golang
Go
8
star
27

pand

Bitwise AND on two byte-slices using SIMD instructions
Go
7
star
28

unik

A k-mer serialization package for Golang
Go
7
star
29

kmers

bit-packed k-mers methods for Golang
Go
7
star
30

install-windows

Windows系统安装经验
6
star
31

perfect-bioinformatic-tools

What should perfect bioinformatic tools be like?
6
star
32

breseq-rm-bg

Removing control/background mutations from breseq output index.html
Go
5
star
33

bbuffer

An alternative of standard library bytes.Buffer
Go
5
star
34

dirsize

Summarize size of directories and files in directories
Go
5
star
35

datakit

CSV/TSV file manipulation and more. Please use my another tool: csvtk, https://github.com/shenwei356/csvtk
Python
4
star
36

util

Golang utility packages
Go
4
star
37

uint64-hash-bench

Benchmark of three uint64 hash functions
Go
3
star
38

simhash-eval

Go
2
star
39

sun2021-cami-profiles

Ground truth metagenomic profiles in CAMI format for the 25 metagenomic reads in Sun et al.
2
star
40

go-hashing-kmer-bench

Benchmark of hashing k-mers in Golang
Go
2
star
41

shenwei356

2
star
42

RNA-HairpinFigure

Draw hairpin-like text figure from RNA sequence and its secondary structure in dot-bracket notation.
Perl
2
star
43

BioUtil

Bioinformatics Perl modules
Perl
2
star
44

rust-practice

Some tools in Rust for learning
2
star
45

todo

A very simple online todo list application
Go
1
star
46

blast-nf

A nextflow-based BLAST command-line helper tool
Nextflow
1
star
47

easy_run

Run command with default options in configuration file
Python
1
star
48

swr

Wei Shen' R utilities
R
1
star
49

shenwei356.github.io

HTML
1
star
50

uintset

Fast uint64 Set in golang
Go
1
star
51

process_queue

Process queue for high CPU/RAM/time usage processes
Perl
1
star
52

roux2016-mock-virome-cami-profile

Ground truth metagenomic profiles in CAMI format for the mock virome communities in Roux et al.
1
star