Tailoring r-index for metagenomics
A basic problem in metagenomics is to assign a sequenced read to the correct species in the reference collection. In typical applications in genomic epidemiology and viral metagenomics the reference collection consists of set of species with each species represented by its highly similar strains. It has been recently shown that accurate read assignment can be achieved with k-mer hashing-based pseudoalignment: A read is assigned to species A if each of its k-mer hits to reference collection is located only on strains of A. We study the underlying primitives required in pseudoalignment and related tasks. We propose three space-efficient solutions building upon the document listing with frequencies problem. All the solutions use an r-index (Gagie et al., SODA 2018) as an underlying index structure for the text obtained as concatenation of the set of species, as well as for each species. Given t species whose concatenation length is n, and whose Burrows-Wheeler transform contains r runs, our first solution, based on a grammar-compressed document array with precomputed queries at non terminal symbols, reports the frequencies for the ndoc distinct documents in which the pattern of length m occurs in O(m + log(n) ndoc) time. Our second solution is also based on a grammar-compressed document array, but enhanced with bitvectors and reports the frequencies in O(m + ((t/w)log n + log(n/r)) ndoc) time, over a machine with wordsize w. Our third solution, based on the interleaved LCP array, answers the same query in O(m + log(n/r) ndoc). We implemented our solutions and tested them on real-world and synthetic datasets. The results show that all the solutions are fast on highly-repetitive data, and the size overhead introduced by the indexes are comparable with the size of the r-index.
READ FULL TEXT