]> git.donarmstrong.com Git - ape.git/blob - man/DNAbin.Rd
8892853ffa41717bf4910283894d62deb7cf9e73
[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 \author{Emmanuel Paradis}
86 \seealso{
87   \code{\link{as.DNAbin}}, \code{\link{read.dna}},
88   \code{\link{read.GenBank}}, \code{\link{write.dna}}, ,
89   \code{\link{image.DNAbin}}
90
91   The corresponding generic functions are documented in the package
92   \pkg{base}.
93 }
94 \examples{
95 data(woodmouse)
96 woodmouse
97 print(woodmouse, 15, 6)
98 print(woodmouse[1:5, 1:300], 15, 6)
99 ### Just to show how distances could be influenced by sampling:
100 dist.dna(woodmouse[1:2, ])
101 dist.dna(woodmouse[1:3, ])
102 ### cbind and its options:
103 x <- woodmouse[1:2, 1:5]
104 y <- woodmouse[2:4, 6:10]
105 as.character(cbind(x, y)) # gives warning
106 as.character(cbind(x, y, fill.with.gaps = TRUE))
107 \dontrun{
108 as.character(cbind(x, y, check.names = FALSE)) # gives an error
109 }
110 }
111 \keyword{manip}