8 \alias{as.matrix.DNAbin}
9 \title{Manipulate DNA Sequences in Bit-Level Format}
11 These functions help to manipulate DNA sequences coded in the
12 bit-level coding scheme.
15 \method{print}{DNAbin}(x, \dots)
16 \method{summary}{DNAbin}(object, printlen = 6, digits = 3, \dots)
17 \method{rbind}{DNAbin}(\dots)
18 \method{cbind}{DNAbin}(\dots, check.names = TRUE, fill.with.gaps = FALSE,
20 \method{[}{DNAbin}(x, i, j, drop = TRUE)
21 \method{as.matrix}{DNAbin}(x, \dots)
22 \method{c}{DNAbin}(\dots, recursive = FALSE)
25 \item{x, object}{an object of class \code{"DNAbin"}.}
26 \item{\dots}{either further arguments to be passed to or from other
27 methods in the case of \code{print}, \code{summary}, and
28 \code{as.matrix}, or a series of objects of class \code{"DNAbin"} in
29 the case of \code{rbind}, \code{cbind}, and \code{c}.}
30 \item{printlen}{the number of labels to print (6 by default).}
31 \item{digits}{the number of digits to print (3 by default).}
32 \item{check.names}{a logical specifying whether to check the rownames
33 before binding the columns (see details).}
34 \item{fill.with.gaps}{a logical indicating whether to keep all
35 possible individuals as indicating by the rownames, and eventually
36 filling the missing data with insertion gaps (ignored if
37 \code{check.names = FALSE}).}
38 \item{quiet}{a logical to switch off warning messages when some rows
40 \item{i, j}{indices of the rows and/or columns to select or to drop.
41 They may be numeric, logical, or character (in the same way than for
43 \item{drop}{logical; if \code{TRUE} (the default), the returned object
44 is of the lowest possible dimension.}
45 \item{recursive}{for compatibility with the generic (unused).}
48 These are all `methods' of generic functions which are here applied to
49 DNA sequences stored as objects of class \code{"DNAbin"}. They are
50 used in the same way than the standard R functions to manipulate
51 vectors, matrices, and lists. Additionally, the operators \code{[[}
52 and \code{$} may be used to extract a vector from a list.
54 These functions are provided to manipulate easily DNA sequences coded
55 with the bit-level coding scheme. The latter allows much faster
56 comparisons of sequences, as well as storing them in less memory
57 compared to the format used before \pkg{ape} 1.10.
59 For \code{cbind}, the default behaviour is to keep only individuals
60 (as indicated by the rownames) for which there are no missing data. If
61 \code{fill.with.gaps = TRUE}, a `complete' matrix is returned,
62 enventually with insertion gaps as missing data. If \code{check.names
63 = TRUE} (the default), the rownames of each matrix are checked, and
64 the rows are reordered if necessary. If \code{check.names = FALSE},
65 the matrices must all have the same number of rows, and are simply
66 binded; the rownames of the first matrix are used. See the examples.
68 \code{as.matrix} may be used to convert DNA sequences (of the same
69 length) stored in a list into a matrix while keeping the names and the
73 an object of class \code{"DNAbin"} in the case of \code{rbind},
74 \code{cbind}, and \code{[}.
77 Paradis, E. (2007) A Bit-Level Coding Scheme for Nucleotides.
78 \url{http://ape.mpl.ird.fr/misc/BitLevelCodingScheme_20April2007.pdf}
80 \author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}}
82 \code{\link{as.DNAbin}}, \code{\link{read.dna}},
83 \code{\link{read.GenBank}}, \code{\link{write.dna}}
85 The corresponding generic functions are documented in the package
92 summary(woodmouse, 15, 6)
93 summary(woodmouse[1:5, 1:300], 15, 6)
94 ### Just to show how distances could be influenced by sampling:
95 dist.dna(woodmouse[1:2, ])
96 dist.dna(woodmouse[1:3, ])
97 ### cbind and its options:
98 x <- woodmouse[1:2, 1:5]
99 y <- woodmouse[2:4, 6:10]
100 as.character(cbind(x, y)) # gives warning
101 as.character(cbind(x, y, fill.with.gaps = TRUE))
103 as.character(cbind(x, y, check.names = FALSE)) # gives an error