typify {tidysq} | R Documentation |
Set type of an sq object
Description
Sets sequence type (and, consequently, alphabet attribute) to one of ami, dna or rna types.
Usage
typify(x, dest_type, ...)
## S3 method for class 'sq'
typify(x, dest_type, ..., NA_letter = getOption("tidysq_NA_letter"))
Arguments
x |
[ |
dest_type |
[ |
... |
further arguments to be passed from or to other methods. |
NA_letter |
[ |
Details
Sometimes functions from I/O module return sequences of incorrect type, most
often unt (which indicates no type). It happens mostly whenever
there are letters that don't fit into target alphabet. After replacing wrong
letters with correct ones with substitute_letters
the user has
sequences of type atp, even if their alphabet is contained in the
target one. At the same time, many functions demand sequences to be of
standard type (i.e. ami, dna or rna) or behave
differently for these.
typify()
is used to help with these situations by allowing the user
to convert their sequences to target type. There are some conditions that
must be met to use this function. The most important is that typified
sq
object must not contain invalid letters. If this condition is not
satisfied, an error is thrown.
If dest_type
is equal to type of sq
, function simply returns
input value.
Value
sq
object with the same letters as input
x
, but with type as specified in dest_type
.
See Also
Functions that manipulate type of sequences:
find_invalid_letters()
,
is.sq()
,
sq_type()
,
substitute_letters()
Examples
# Constructing sq object with strange characters (type will be set to "unt"):
sq_unt <- sq(c("&VPLG&#", "##LCG"))
# Substituting letters with "X", which stands for unknown amino acid:
sq_sub <- substitute_letters(sq_unt, c(`&` = "X", `#` = "X"))
# Setting extended amino acid type (only extended one has "X" letter):
typify(sq_sub, "ami_ext")