]> git.donarmstrong.com Git - ape.git/blob - man/DNAbin.Rd
b08446f6005a67dae11e2b9503a3f76bb14112e7
[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 \alias{c.DNAbin}
10 \title{Manipulate DNA Sequences in Bit-Level Format}
11 \description{
12   These functions help to manipulate DNA sequences coded in the
13   bit-level coding scheme.
14 }
15 \usage{
16 \method{print}{DNAbin}(x, \dots)
17 \method{summary}{DNAbin}(object, printlen = 6, digits = 3, \dots)
18 \method{rbind}{DNAbin}(\dots)
19 \method{cbind}{DNAbin}(\dots, check.names = TRUE, fill.with.gaps = FALSE,
20              quiet = FALSE)
21 \method{[}{DNAbin}(x, i, j, drop = TRUE)
22 \method{as.matrix}{DNAbin}(x, \dots)
23 \method{c}{DNAbin}(\dots, recursive = FALSE)
24 }
25 \arguments{
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{summary}, and
29     \code{as.matrix}, or a series of objects of class \code{"DNAbin"} in
30     the 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
40     are dropped.}
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
43     standard R objects).}
44   \item{drop}{logical; if \code{TRUE} (the default), the returned object
45     is of the lowest possible dimension.}
46   \item{recursive}{for compatibility with the generic (unused).}
47 }
48 \details{
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.
54
55   These functions are provided to manipulate easily DNA sequences coded
56   with the bit-level coding scheme. The latter allows much faster
57   comparisons of sequences, as well as storing them in less memory
58   compared to the format used before \pkg{ape} 1.10.
59
60   For \code{cbind}, the default behaviour is to keep only individuals
61   (as indicated by the rownames) for which there are no missing data. If
62   \code{fill.with.gaps = TRUE}, a `complete' matrix is returned,
63   enventually with insertion gaps as missing data. If \code{check.names
64   = TRUE} (the default), the rownames of each matrix are checked, and
65   the rows are reordered if necessary. If \code{check.names = FALSE},
66   the matrices must all have the same number of rows, and are simply
67   binded; the rownames of the first matrix are used. See the examples.
68
69   \code{as.matrix} may be used to convert DNA sequences (of the same
70   length) stored in a list into a matrix while keeping the names and the
71   class.
72 }
73 \value{
74   an object of class \code{"DNAbin"} in the case of \code{rbind},
75   \code{cbind}, and \code{[}.
76 }
77 \references{
78   Paradis, E. (2007) A Bit-Level Coding Scheme for Nucleotides.
79   \url{http://ape.mpl.ird.fr/misc/BitLevelCodingScheme_20April2007.pdf}
80 }
81 \author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}}
82 \seealso{
83   \code{\link{as.DNAbin}}, \code{\link{read.dna}},
84   \code{\link{read.GenBank}}, \code{\link{write.dna}}
85
86   The corresponding generic functions are documented in the package
87   \pkg{base}.
88 }
89 \examples{
90 data(woodmouse)
91 woodmouse
92 summary(woodmouse)
93 summary(woodmouse, 15, 6)
94 summary(woodmouse[1:5, 1:300], 15, 6)
95 ### Just to show how distances could be influenced by sampling:
96 dist.dna(woodmouse[1:2, ])
97 dist.dna(woodmouse[1:3, ])
98 ### cbind and its options:
99 x <- woodmouse[1:2, 1:5]
100 y <- woodmouse[2:4, 6:10]
101 as.character(cbind(x, y)) # gives warning
102 as.character(cbind(x, y, fill.with.gaps = TRUE))
103 \dontrun{
104 as.character(cbind(x, y, check.names = FALSE)) # gives an error
105 }
106 }
107 \keyword{manip}