R/count_multimers.R
count_multimers.Rd
This is a wrapper over count_kmers function in order to enable the computation of many types of k-mers in a single invocation of the function.
A user can input multiple k-mer configurations in the following way.
Each parameter that is related to the configuration
(i.e., k_vector
, positional_vector
, and kmer_gaps_list
)
is represented in a sequential form (i.e., a list or a vector).
The i-th entry of each sequence corresponds to the i-th configuration.
count_multimers( sequences, k_vector, kmer_alphabet = getOption("seqR_kmer_alphabet_default"), positional_vector = rep(getOption("seqR_positional_default"), length(k_vector)), kmer_gaps_list = rep(list(c()), length(k_vector)), with_kmer_counts = getOption("seqR_with_kmer_counts_default"), with_kmer_names = getOption("seqR_with_kmer_names_default"), batch_size = getOption("seqR_batch_size_default"), hash_dim = getOption("seqR_hash_dim_default"), verbose = getOption("seqR_verbose_default") )
sequences | input sequences of one of two supported types,
either |
---|---|
k_vector | an |
kmer_alphabet | a |
positional_vector | a |
kmer_gaps_list | a |
with_kmer_counts | a single |
with_kmer_names | a single |
batch_size | a single |
hash_dim | a single |
verbose | a single |
a Matrix
value that represents a result k-mer matrix.
The result is a sparse matrix in order to reduce memory consumption.
The i-th row of the matrix represents k-mers found in the i-th input sequence.
Each column represents a distinct k-mer.
The names of columns conform to human-readable schema for k-mers,
if parameter with_kmer_names = TRUE
The comprehensive description of supported features is available
in vignette("features-overview", package = "seqR")
.
Function that count k-mers of one type: count_kmers
Function that merges several k-mer matrices (rbind): rbind_columnwise
batch_size <- 1 # Counting 1-mers count_multimers( c("AAAACFVV", "AAAAAA", "AAAAD"), k_vector = c(1), batch_size=batch_size)#>#> 3 x 5 sparse Matrix of class "dgCMatrix" #> C A F V D #> [1,] 1 4 1 2 . #> [2,] . 6 . . . #> [3,] . 4 . . 1# Counting 1-mers and 2-mers count_multimers( c("AAAACFVV", "AAAAAA", "AAAAD"), k_vector = c(1, 2), batch_size = batch_size)#>#> 3 x 11 sparse Matrix of class "dgCMatrix"#>#> #> [1,] 1 4 1 2 . 3 1 1 1 1 . #> [2,] . 6 . . . 5 . . . . . #> [3,] . 4 . . 1 3 . . . . 1# Counting 1-mers, 2-mers, and gapped 2-mers with the length of the gap = 1 count_multimers( c("AAAACFVV", "AAAAAA", "AAAAD"), k_vector = c(1, 2, 2), kmer_gaps = list(NULL, NULL, c(1)), batch_size=batch_size)#>#> 3 x 17 sparse Matrix of class "dgCMatrix"#>#> #> [1,] 1 4 1 2 . 3 1 1 1 1 . 2 1 1 1 1 . #> [2,] . 6 . . . 5 . . . . . 4 . . . . . #> [3,] . 4 . . 1 3 . . . . 1 2 . . . . 1# Counting 3-mers, positional 3-mers, and positional gapped 2-mers with the length of the gap = 1 count_multimers( c("AAAACFVV", "AAAAAA", "AAAAD"), k_vector = c(3, 3, 2), kmer_gaps_list = list(NULL, NULL, c(1)), positional_vector = c(FALSE, TRUE, TRUE), batch_size=batch_size)#>#> 3 x 24 sparse Matrix of class "dgCMatrix"#>#> #> [1,] 1 1 2 1 1 . 1 1 1 1 1 1 . . . 1 1 1 1 1 1 . . . #> [2,] . . 4 . . . 1 1 . . . . 1 1 . . . . . 1 1 1 1 . #> [3,] . . 2 . . 1 1 1 . . . . . . 1 . . . . 1 1 . . 1