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