This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Counting Kmers With Reverse Complement?

What is a good tool to count the number of k-mers (with k being > 30), where we say that the reverse complement of a k-mer is the same as the k-mer itself? In other words, I would want ACCT and AGGT to count as the same k-mer. Does tallymer do this?

Thanks.

counts

2 answers

I like [?]jellyfish[?] for k-mer counting. Great for large genomes. It has a -C parameters that'll count both strands.

Well, I do want to count both strands, but more importantly, I want to make sure that ACCT and AGGT is counted once and not twice. It doesn't appear that Jellyfish does that, but I could be mistaken.

@Bob. If you use the -C flag, then one occurrence of ACCT and one occurrence of AGGT would count as two occurrences of a ACCT/AGGT kmer. The output file will just show ACCT or AGGT with the count, but I'm not sure how it decides which to use.

I am assuming you want kmers on the opposite strands to be merged if they are derived from different strands. In other words if you had the sequence ACCTG you would have 4 4mers.

ACCT
CCTG
CAGG (reverse complement)
AGGT (reverse complement)

Resulting in the counts:

ACCT --> 2
CCTG --> 2

Since you are essentially reverse complementing the reverse complement of a kmer to "merge" their counts you can just count all the kmers on the forward strand and then double it.

Forward strand:

ATGG
TGGC
GGCC

Reverse complement: GGCCAT, and each kmer is then reverse complemented again:

GGCC --> GGCC
GCCA --> CGGT
CCAT --> ATGG

As you can see you get the exact same kmers.

Log in to answer this question.