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