knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
[![codecov.io](https://app.codecov.io/github/fmichonneau/phylobase?branch=master)
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.
The stable version (the minor and patch version numbers are even, e.g., 0.6.8) can be downloaded from CRAN.
install.packages("phylobase")
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 devtools
package.
pak::install_github("fmichonneau/phylobase") library(phylobase)
library(phylobase)
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 \emph{Geospiza} data from \verb+geospiza_raw$data+ and merge it with the tree. However, since \emph{G. olivacea} 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)
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") head(g2)
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.
myrmeFile <- system.file("nexusfiles/treeWithDiscreteData.nex", package="phylobase") myrme <- readNexus(file=myrmeFile) head(myrme)
library(RNeXML) nxmlFile <- system.file("nexmlfiles/comp_analysis.xml", package="phylobase") nxml <- nexml_read(nxmlFile) nxmlEx <- phylo4(nxml)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.