Sets sequence type (and, consequently, alphabet attribute) to one of ami, dna or rna types.

typify(x, dest_type, ...)

# S3 method for sq
typify(x, dest_type, ..., NA_letter = getOption("tidysq_NA_letter"))

Arguments

x

[sq]
An object this function is applied to.

dest_type

[character(1)]
The name of destination type - one of "dna_bsc", "dna_ext", "rna_bsc", "rna_ext", "ami_bsc" and "ami_ext".

...

further arguments to be passed from or to other methods.

NA_letter

[character(1)]
A string that is used to interpret and display NA value in the context of sq class. Default value equals to "!".

Value

sq object with the same letters as input x, but with type as specified in dest_type.

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.

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")
#> extended amino acid sequences list:
#> [1] XVPLGXX                                                                  <7>
#> [2] XXLCG                                                                    <5>