conversion {insect} | R Documentation |
Convert sequences between binary and character string formats.
Description
These functions convert DNA and amino acid sequences in "DNAbin" or "AAbin" format to concatenated character strings, and vice versa.
Usage
dna2char(x)
aa2char(x)
char2dna(z, simplify = FALSE)
char2aa(z, simplify = FALSE)
Arguments
x |
a "DNAbin" or "AAbin" object. |
z |
a vector of concatenated strings representing DNA or amino acid sequences in upper case. |
simplify |
logical indicating whether length-one "DNAbin" or "AAbin" objects should be simplified to vectors. Defaults to FALSE. |
Details
These functions are used to convert concatenated character strings
(e.g. "TAACGC") to binary format and vice versa.
To convert DNAbin and AAbin objects to non-concatenated
character objects (e.g. c("T", "A", "A", "C", "G", "C")
)
refer to the ape
package functions
as.character.DNAbin
and
as.character.AAbin
.
Likewise the ape
package functions
as.DNAbin
and as.AAbin
are used to convert non-concatenated character
objects to binary format.
Value
dna2char
and aa2char
return vectors of upper case
character strings.
char2dna
and char2aa
return "DNAbin" and "AAbin" objects,
respectively. These will be lists unless the input object
has length one and simplify = TRUE, in which case the returned object
will be a vector.
Author(s)
Shaun Wilkinson
References
Paradis E, Claude J, Strimmer K, (2004) APE: analyses of phylogenetics and evolution in R language. Bioinformatics 20, 289-290.
Paradis E (2007) A bit-level coding scheme for nucleotides. http://ape-package.ird.fr/misc/BitLevelCodingScheme.html.
Paradis E (2012) Analysis of Phylogenetics and Evolution with R (Second Edition). Springer, New York.
Examples
char2dna("TAACGC")
char2aa("VGAHAGEY")
dna2char(char2dna("TAACGC"))
aa2char(char2aa("VGAHAGEY"))
char2dna(list(seq1 = "TAACGC", seq2 = "ATTGCG"))
char2aa(list(seq1 = "VGAHAGEY", seq2 = "VNVDEV"))