]> git.donarmstrong.com Git - ape.git/blob - man/DNAbin.Rd
a191f9950cda149c73131433ec4edb62a52da4f0
[ape.git] / man / DNAbin.Rd
1 \name{DNAbin}
2 \alias{DNAbin}
3 \alias{print.DNAbin}
4 \alias{summary.DNAbin}
5 \alias{[.DNAbin}
6 \alias{rbind.DNAbin}
7 \alias{cbind.DNAbin}
8 \alias{as.matrix.DNAbin}
9 \title{Manipulate DNA Sequences in Bit-Level Format}
10 \description{
11   These functions help to manipulate DNA sequences coded in the
12   bit-level coding scheme.
13 }
14 \usage{
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,
19              quiet = FALSE)
20 \method{[}{DNAbin}(x, i, j, drop = TRUE)
21 \method{as.matrix}{DNAbin}(x, \dots)
22 \method{c}{DNAbin}(\dots, recursive = FALSE)
23 }
24 \arguments{
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
39     are dropped.}
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
42     standard R objects).}
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).}
46 }
47 \details{
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.
53
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.
58
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.
67
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
70   class.
71 }
72 \value{
73   an object of class \code{"DNAbin"} in the case of \code{rbind},
74   \code{cbind}, and \code{[}.
75 }
76 \references{
77   Paradis, E. (2007) A Bit-Level Coding Scheme for Nucleotides.
78   \url{http://ape.mpl.ird.fr/misc/BitLevelCodingScheme_20April2007.pdf}
79 }
80 \author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}}
81 \seealso{
82   \code{\link{as.DNAbin}}, \code{\link{read.dna}},
83   \code{\link{read.GenBank}}, \code{\link{write.dna}}
84
85   The corresponding generic functions are documented in the package
86   \pkg{base}.
87 }
88 \examples{
89 data(woodmouse)
90 woodmouse
91 summary(woodmouse)
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))
102 \dontrun{
103 as.character(cbind(x, y, check.names = FALSE)) # gives an error
104 }
105 }
106 \keyword{manip}