Manipulate DNA Sequences in Bit-Level Format

These functions help to manipulate DNA sequences coded in the bit-level coding scheme.

## S3 method for class 'DNAbin':
print(x, \dots)
## S3 method for class 'DNAbin':
summary(object, printlen = 6, digits = 3, \dots)
## S3 method for class 'DNAbin':
## S3 method for class 'DNAbin':
cbind(\dots, check.names = TRUE)
## S3 method for class 'DNAbin':
[(x, i, j, drop = TRUE)
## S3 method for class 'DNAbin':
as.matrix(x, \dots)
x, object
an object of class "DNAbin".
either further arguments to be passed to or from other methods in the case of print, summary, and as.matrix, or a series of objects of class "DNAbin" in the case of rbind and
the number of labels to print (6 by default).
the number of digits to print (3 by default).
a logical specifying whether to check the rownames before binding the columns (see details).
i, j
indices of the rows and/or columns to select or to drop. They may be numeric, logical, or character (in the same way than for standard R objects).
logical; if TRUE (the default), the returned object is of the lowest possible dimension.

These are all `methods' of generic functions which are here applied to DNA sequences stored as objects of class "DNAbin". They are used in the same way than the standard R functions to manipulate vectors, matrices, and lists. Additionally, the operators [[ and $ may be used to extract a vector from a list.

These functions are provided to manipulate easily DNA sequences coded with the bit-level coding scheme. The latter allows much faster comparisons of sequences, as well as storing them in less memory compared to the format used before ape 1.10.

For cbind, if "check.names = TRUE", the rownames of each matrix are checked, and the rows are reordered if necessary. If the rownames differ among matrices, an error occurs. If "check.names = FALSE", the matrices are simply binded and the rownames of the first matrix are used.

as.matrix may be used to convert DNA sequences (of the same length) stored in a list into a matrix while keeping the names and the class.


  • an object of class "DNAbin" in the case of rbind, cbind, and [.


Paradis, E. (2007) A Bit-Level Coding Scheme for Nucleotides. http://pbil.univ-lyon1.fr/R/ape/misc/BitLevelCodingScheme_20April2007.pdf

See Also

as.DNAbin, read.dna, read.GenBank, write.dna

The corresponding generic functions are documented in the package base.

  • DNAbin
  • print.DNAbin
  • summary.DNAbin
  • [.DNAbin
  • rbind.DNAbin
  • cbind.DNAbin
  • as.matrix.DNAbin
summary(woodmouse, 15, 6)
summary(woodmouse[1:5, 1:300], 15, 6)
### Just to show how distances could be influenced by sampling:
dist.dna(woodmouse[1:2, ])
dist.dna(woodmouse[1:3, ])
Documentation reproduced from package ape, version 2.1-1, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.