kmerCounts: Count occurrences of k-mer

Description Usage Arguments Value Examples

View source: R/sarks.R

Description

Counts how often a k-mer (or vector of k-mers) occurs in each element of a character vector.

Usage

1
kmerCounts(kmer, seqs, directional = TRUE, overlap = FALSE)

Arguments

kmer

character vector or XStringSet of k-mers to search for.

seqs

character vector or XStringSet of sequences in which to search for and count occurrences of kmer.

directional

logical value: if FALSE, counts occurrences of either kmer or its reverse-complement. Makes sense only if applying to DNA sequences!

overlap

logical value: should overlapping occurrences of kmer be counted as multiple hits?

Value

if length(kmer) is one, returns integer vector of counts; if length(kmer) is more than one, returns matrix of counts: one row per sequence in seqs, one column per expression in regex

Examples

1
2
3
4
5
6
7
data(simulatedSeqs)
motifCounts <- kmerCounts('CATACTGAGA', simulatedSeqs)
otherCounts <- kmerCounts(
    c('AAAAA', 'CG'),
    simulatedSeqs,
    directional = FALSE
)

sarks documentation built on Nov. 8, 2020, 6:54 p.m.