Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

DNAbin

Manipulate DNA Sequences in Bit-Level Format


Description

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

Usage

## S3 method for class 'DNAbin'
print(x, printlen = 6, digits = 3, ...)
## S3 method for class 'DNAbin'
rbind(...)
## S3 method for class 'DNAbin'
cbind(..., check.names = TRUE, fill.with.gaps = FALSE,
             quiet = FALSE)
## S3 method for class 'DNAbin'
x[i, j, drop = FALSE]
## S3 method for class 'DNAbin'
as.matrix(x, ...)
## S3 method for class 'DNAbin'
c(..., recursive = FALSE)
## S3 method for class 'DNAbin'
as.list(x, ...)
## S3 method for class 'DNAbin'
labels(object, ...)

Arguments

x, object

an object of class "DNAbin".

...

either further arguments to be passed to or from other methods in the case of print, as.matrix, and labels, or a series of objects of class "DNAbin" in the case of rbind, cbind, and c.

printlen

the number of labels to print (6 by default).

digits

the number of digits to print (3 by default).

check.names

a logical specifying whether to check the rownames before binding the columns (see details).

fill.with.gaps

a logical indicating whether to keep all possible individuals as indicating by the rownames, and eventually filling the missing data with insertion gaps (ignored if check.names = FALSE).

quiet

a logical to switch off warning messages when some rows are dropped.

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).

drop

logical; if TRUE, the returned object is of the lowest possible dimension.

recursive

for compatibility with the generic (unused).

Details

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. Note that the default of drop is not the same than the generic operator: this is to avoid dropping rownames when selecting a single sequence.

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, the default behaviour is to keep only individuals (as indicated by the rownames) for which there are no missing data. If fill.with.gaps = TRUE, a ‘complete’ matrix is returned, enventually with insertion gaps as missing data. If check.names = TRUE (the default), the rownames of each matrix are checked, and the rows are reordered if necessary (if some rownames are duplicated, an error is returned). If check.names = FALSE, the matrices must all have the same number of rows, and are simply binded; the rownames of the first matrix are used. See the examples.

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. as.list does the reverse operation.

Value

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

Author(s)

Emmanuel Paradis

References

Paradis, E. (2007) A Bit-Level Coding Scheme for Nucleotides. http://ape-package.ird.fr/misc/BitLevelCodingScheme_20April2007.pdf

Paradis, E. (2012) Analysis of Phylogenetics and Evolution with R (Second Edition). New York: Springer.

See Also

The corresponding generic functions are documented in the package base.

Examples

data(woodmouse)
woodmouse
print(woodmouse, 15, 6)
print(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, ])
### cbind and its options:
x <- woodmouse[1:2, 1:5]
y <- woodmouse[2:4, 6:10]
as.character(cbind(x, y)) # gives warning
as.character(cbind(x, y, fill.with.gaps = TRUE))
## Not run: 
as.character(cbind(x, y, check.names = FALSE)) # gives an error

## End(Not run)

ape

Analyses of Phylogenetics and Evolution

v5.5
GPL-2 | GPL-3
Authors
Emmanuel Paradis [aut, cre, cph] (<https://orcid.org/0000-0003-3092-2199>), Simon Blomberg [aut, cph] (<https://orcid.org/0000-0003-1062-0839>), Ben Bolker [aut, cph] (<https://orcid.org/0000-0002-2127-0443>), Joseph Brown [aut, cph] (<https://orcid.org/0000-0002-3835-8062>), Santiago Claramunt [aut, cph] (<https://orcid.org/0000-0002-8926-5974>), Julien Claude [aut, cph] (<https://orcid.org/0000-0002-9267-1228>), Hoa Sien Cuong [aut, cph], Richard Desper [aut, cph], Gilles Didier [aut, cph] (<https://orcid.org/0000-0003-0596-9112>), Benoit Durand [aut, cph], Julien Dutheil [aut, cph] (<https://orcid.org/0000-0001-7753-4121>), RJ Ewing [aut, cph], Olivier Gascuel [aut, cph], Thomas Guillerme [aut, cph] (<https://orcid.org/0000-0003-4325-1275>), Christoph Heibl [aut, cph] (<https://orcid.org/0000-0002-7655-3299>), Anthony Ives [aut, cph] (<https://orcid.org/0000-0001-9375-9523>), Bradley Jones [aut, cph] (<https://orcid.org/0000-0003-4498-1069>), Franz Krah [aut, cph] (<https://orcid.org/0000-0001-7866-7508>), Daniel Lawson [aut, cph] (<https://orcid.org/0000-0002-5311-6213>), Vincent Lefort [aut, cph], Pierre Legendre [aut, cph] (<https://orcid.org/0000-0002-3838-3305>), Jim Lemon [aut, cph], Guillaume Louvel [aut, cph] (<https://orcid.org/0000-0002-7745-0785>), Eric Marcon [aut, cph] (<https://orcid.org/0000-0002-5249-321X>), Rosemary McCloskey [aut, cph] (<https://orcid.org/0000-0002-9772-8553>), Johan Nylander [aut, cph], Rainer Opgen-Rhein [aut, cph], Andrei-Alin Popescu [aut, cph], Manuela Royer-Carenzi [aut, cph], Klaus Schliep [aut, cph] (<https://orcid.org/0000-0003-2941-0161>), Korbinian Strimmer [aut, cph] (<https://orcid.org/0000-0001-7917-2056>), Damien de Vienne [aut, cph] (<https://orcid.org/0000-0001-9532-5251>)
Initial release
2021-04-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.