Table of Contents
Fetching ...

Computing k-mers in Graphs

Jarno N. Alanko, Maximo Perez-Lopez

TL;DR

It is shown that distinct $k$-mers of such a graph $W=(V, E)$ can be counted using $O(|W|k)$ or $O(n^4 \log k)$ arithmetic operations, where $n=|V|$, $m=|E|$ and $|W|=n+m$.

Abstract

We initiate the study of computational problems on $k$-mers (strings of length $k$) in labeled graphs. As a starting point, we consider the problem of counting the number of distinct $k$-mers found on the walks of a graph. We establish that this is $\#$P-hard, even on connected deterministic DAGs. However, in the class of deterministic Wheeler graphs (Gagie, Manzini, and Sirèn, TCS 2017), we show that distinct $k$-mers of such a graph $W=(V, E)$ can be counted using $O(|W|k)$ or $O(n^4 \log k)$ arithmetic operations, where $n=|V|$, $m=|E|$ and $|W|=n+m$. The latter result uses a new generalization of the technique of prefix doubling to Wheeler graphs. To generalize our results beyond Wheeler graphs, we discuss ways to transform a graph into a Wheeler graph in a manner that preserves the $k$-mers. As an application of our $k$-mer counting algorithms, we construct a representation of the de Bruijn graph of the $k$-mers that occupies $O(n_k + |W|k \log(\max_{1 \leq \ell \leq k} n_\ell) + σ\log m)$ bits of space, where $n_\ell$ is the number of distinct $\ell$-mers in the Wheeler graph, and $σ$ is the size of the alphabet. We show how to construct it in the same time complexity. Given that the Wheeler graph can be exponentially smaller than the de Bruijn graph, for large $k$ this provides a theoretical improvement over previous de Bruijn graph construction methods from graphs, which must spend $Ω(k)$ time per $k$-mer in the graph.

Computing k-mers in Graphs

TL;DR

It is shown that distinct -mers of such a graph can be counted using or arithmetic operations, where , and .

Abstract

We initiate the study of computational problems on -mers (strings of length ) in labeled graphs. As a starting point, we consider the problem of counting the number of distinct -mers found on the walks of a graph. We establish that this is P-hard, even on connected deterministic DAGs. However, in the class of deterministic Wheeler graphs (Gagie, Manzini, and Sirèn, TCS 2017), we show that distinct -mers of such a graph can be counted using or arithmetic operations, where , and . The latter result uses a new generalization of the technique of prefix doubling to Wheeler graphs. To generalize our results beyond Wheeler graphs, we discuss ways to transform a graph into a Wheeler graph in a manner that preserves the -mers. As an application of our -mer counting algorithms, we construct a representation of the de Bruijn graph of the -mers that occupies bits of space, where is the number of distinct -mers in the Wheeler graph, and is the size of the alphabet. We show how to construct it in the same time complexity. Given that the Wheeler graph can be exponentially smaller than the de Bruijn graph, for large this provides a theoretical improvement over previous de Bruijn graph construction methods from graphs, which must spend time per -mer in the graph.

Paper Structure

This paper contains 19 sections, 13 theorems, 6 equations, 2 figures.

Key Result

Lemma 2

In deterministic Wheeler graphs, for any pair of edges, $(u,v,a), (u',v',a')$ we have $(a = a' \wedge v<v') \Rightarrow u < u'$. $\qed$

Figures (2)

  • Figure 1: Reduction from the example DNF formula $F=(x_1\wedge x_3) \vee(\neg x_1\wedge x_2)\vee(\neg x_1\wedge \neg x_3)$, to counting $3$-mers. Note how $d_1=1, d_2=0, d_3=1$ and thus $\#SAT(F)=10-2^1-2^0-2^1=5$.
  • Figure 2: Example of a Wheeler graph, with an illustration of how we compute the $4$-mer counts of vertex $6$. The $2$-mers encapsulated with a box are black, and the rest are white. With the information on the table, we can calculate $T_4([1,6],6) = T^W_2([1,6],3)\cdot C_2(3,6)+T_2([1,2],6)=2$.

Theorems & Definitions (15)

  • Definition 1
  • Lemma 2
  • Theorem 3
  • Corollary 4
  • Corollary 5
  • Lemma 5
  • Corollary 6
  • Lemma 6
  • Theorem 7
  • Theorem 8
  • ...and 5 more