sqapply | R Documentation |
Applies given function to each sequence. Sequences are passed to function as character vectors
(or numeric, if type of sq
is enc) or single character strings, depending on
parameter.
sqapply(x, fun, ...)
## S3 method for class 'sq'
sqapply(
x,
fun,
...,
single_string = FALSE,
NA_letter = getOption("tidysq_NA_letter")
)
x |
[ |
fun |
[ |
... |
further arguments to be passed from or to other methods. |
single_string |
[ |
NA_letter |
[ |
A list of values returned by function for each sequence in corresponding order.
sq
lapply
# Creating objects to work on:
sq_dna <- sq(c("ATGCAGGA", "GACCGNBAACGAN", "TGACGAGCTTA"),
alphabet = "dna_bsc")
sq_ami <- sq(c("MIAANYTWIL","TIAALGNIIYRAIE", "NYERTGHLI", "MAYXXXIALN"),
alphabet = "ami_ext")
sq_unt <- sq(c("ATGCAGGA?", "TGACGAGCTTA", "", "TIAALGNIIYRAIE"))
# Counting how may "A" elements are present in sequences:
sqapply(sq_dna, function(sequence) sum(sequence == "A"))
sqapply(sq_ami, function(sequence) sum(sequence == "A"))
sqapply(sq_unt, function(sequence) sum(sequence == "A"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.