phylobase provides classes and methods to easily associate,
manipulate, explore, and plot phylogenetic trees and data about the
species they include. The goal of this package is to provide a base set
of tools likely to be shared by all packages designed for phylogenetic
analysis. This standardization will benefit both end-users by allowing
them to move results across packages and keep data associated with the
phylogenetic trees; and developers by focusing on method development
instead of having to rewrite the base functions.
Authors: R Hackathon et al. (alphabetically: Ben Bolker, Marguerite
Butler, Peter Cowan, Damien de Vienne, Dirk Eddelbuettel, Mark
Holder, Thibaut Jombart, Steve Kembel, Francois Michonneau, David
Orme, Brian O’Meara, Emmanuel Paradis, Jim Regetz, Derrick Zwickl)
phylobase comes with example data sets geospiza and geospiza_raw.
geospiza is a phylo4d object (the phylobase class that holds
together a phylogenetic tree and associated data, the phylo4 class
is for phylogenetic trees only).
geospiza_raw is a list that contains the tree geospiza_raw$tree
(as an ape::phylo object) and the data geospiza_raw$data (as a
data.frame) that were used to build the geospiza object.
Now we’ll take the data from and merge it with the tree. However, since
is included in the tree but not in the data set, we will initially run
into some trouble:
data(geospiza_raw)
g1 <- as(geospiza_raw$tree, "phylo4")
geodata <- geospiza_raw$data
g2 <- phylo4d(g1, geodata)
#> Error in formatData(phy = x, dt = tip.data, type = "tip", ...): The following nodes are not found in the dataset: olivacea
To deal with G. olivacea missing from the data, we have a few choices.
The easiest is to use missing.data="warn" to allow R to create the
new object with a warning (you can also use missing.data="OK" to
proceed without warnings):
g2 <- phylo4d(g1, geodata, missing.data="warn")
#> Warning in formatData(phy = x, dt = tip.data, type = "tip", ...): The following
#> nodes are not found in the dataset: olivacea
head(g2)
#> label node ancestor edge.length node.type wingL tarsusL culmenL
#> 1 fuliginosa 1 24 0.05500 tip 4.132957 2.806514 2.094971
#> 2 fortis 2 24 0.05500 tip 4.244008 2.894717 2.407025
#> 3 magnirostris 3 23 0.11000 tip 4.404200 3.038950 2.724667
#> 4 conirostris 4 22 0.18333 tip 4.349867 2.984200 2.654400
#> 5 scandens 5 21 0.19250 tip 4.261222 2.929033 2.621789
#> 6 difficilis 6 20 0.22800 tip 4.224067 2.898917 2.277183
#> 7 pallida 7 25 0.08667 tip 4.265425 3.089450 2.430250
#> 8 parvulus 8 27 0.02000 tip 4.131600 2.973060 1.974420
#> 9 psittacula 9 27 0.02000 tip 4.235020 3.049120 2.259640
#> 10 pauper 10 26 0.03500 tip 4.232500 3.035900 2.187000
#> 11 Platyspiza 11 18 0.46550 tip 4.419686 3.270543 2.331471
#> 12 fusca 12 17 0.53409 tip 3.975393 2.936536 2.051843
#> 13 Pinaroloxias 13 16 0.58333 tip 4.188600 2.980200 2.311100
#> 14 olivacea 14 15 0.88077 tip NA NA NA
#> 15 <NA> 15 0 NA root NA NA NA
#> 16 <NA> 16 15 0.29744 internal NA NA NA
#> 17 <NA> 17 16 0.04924 internal NA NA NA
#> 18 <NA> 18 17 0.06859 internal NA NA NA
#> 19 <NA> 19 18 0.13404 internal NA NA NA
#> 20 <NA> 20 19 0.10346 internal NA NA NA
#> beakD gonysW
#> 1 1.941157 1.845379
#> 2 2.362658 2.221867
#> 3 2.823767 2.675983
#> 4 2.513800 2.360167
#> 5 2.144700 2.036944
#> 6 2.011100 1.929983
#> 7 2.016350 1.949125
#> 8 1.873540 1.813340
#> 9 2.230040 2.073940
#> 10 2.073400 1.962100
#> 11 2.347471 2.282443
#> 12 1.191264 1.401186
#> 13 1.547500 1.630100
#> 14 NA NA
#> 15 NA NA
#> 16 NA NA
#> 17 NA NA
#> 18 NA NA
#> 19 NA NA
#> 20 NA NA
Importing data
From NEXUS files
phylobase has a robust parser for NEXUS files (it uses the NEXUS Class
Library from Paul Lewis and Mark Holder,
NCL). It can be used to
import simultaneously tree and species data.
phylobase
About this package
phylobaseprovides classes and methods to easily associate, manipulate, explore, and plot phylogenetic trees and data about the species they include. The goal of this package is to provide a base set of tools likely to be shared by all packages designed for phylogenetic analysis. This standardization will benefit both end-users by allowing them to move results across packages and keep data associated with the phylogenetic trees; and developers by focusing on method development instead of having to rewrite the base functions.Installation
Stable version
The stable version (the minor and patch version numbers are even, e.g., 0.6.8) can be downloaded from CRAN.
Development version
The development version (the patch version number is odd, e.g., 0.6.9) is available on GitHub (https://github.com/fmichonneau/phylobase), and can be installed using the
devtoolspackage.Getting started
phylobasecomes with example data setsgeospizaandgeospiza_raw.geospizais aphylo4dobject (thephylobaseclass that holds together a phylogenetic tree and associated data, thephylo4class is for phylogenetic trees only).geospiza_rawis a list that contains the treegeospiza_raw$tree(as anape::phyloobject) and the datageospiza_raw$data(as adata.frame) that were used to build thegeospizaobject.Now we’ll take the data from and merge it with the tree. However, since is included in the tree but not in the data set, we will initially run into some trouble:
To deal with G. olivacea missing from the data, we have a few choices. The easiest is to use
missing.data="warn"to allowRto create the new object with a warning (you can also usemissing.data="OK"to proceed without warnings):Importing data
From NEXUS files
phylobasehas a robust parser for NEXUS files (it uses the NEXUS Class Library from Paul Lewis and Mark Holder, NCL). It can be used to import simultaneously tree and species data.From NeXML