Joins sequences from a vector into a single sequence. Sequence type remains unchanged.
collapse(x, ...)# S3 method for sq
collapse(x, ..., NA_letter = getOption("tidysq_NA_letter"))
sq
object of the same type as input but with
exactly one sequence.
[sq
]
An object this function is applied to.
further arguments to be passed from or to other methods.
[character(1)
]
A string that is used to interpret and display NA
value in the
context of sq class
. Default value equals to
"!
".
collapse()
joins sequences from supplied sq
object in the same
order as they appear in said vector. That is, if there are three sequences
AGGCT, ATCCGT and GAACGT, then resulting sequence will be AGGCTATCCGTGAACGT.
This operation does not alter the type of the input object nor its alphabet.
Functions that affect order of elements:
bite()
,
paste()
,
reverse()
# Creating objects to work on:
sq_ami <- sq(c("MIAANYTWIL","TIAALGNIIYRAIE", "NYERTGHLI", "MAYXXXIALN"),
alphabet = "ami_ext")
sq_dna <- sq(c("ATGCAGGA", "GACCGAACGAN", ""), alphabet = "dna_ext")
sq_unt <- sq(c("ATGCAGGA?", "TGACGAGCTTA", "", "TIAALGNIIYRAIE"))
# Collapsing sequences:
collapse(sq_ami)
collapse(sq_dna)
collapse(sq_unt)
# Empty sq objects are collapsed as well (into empty string - ""):
sq_empty <- sq(character(), alphabet = "rna_bsc")
collapse(sq_empty)
Run the code above in your browser using DataLab