knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

phylobase

R-CMD-check [![codecov.io](https://app.codecov.io/github/fmichonneau/phylobase?branch=master) CRAN version

About this package

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.

Installation

Stable version

The stable version (the minor and patch version numbers are even, e.g., 0.6.8) can be downloaded from CRAN.

install.packages("phylobase")

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 devtools package.

pak::install_github("fmichonneau/phylobase")
library(phylobase)

Getting started

library(phylobase)

phylobase comes with example data sets geospiza and geospiza_raw.

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)

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.

myrmeFile <- system.file("nexusfiles/treeWithDiscreteData.nex", package="phylobase")
myrme <- readNexus(file=myrmeFile)
head(myrme)

From NeXML

library(RNeXML)
nxmlFile <- system.file("nexmlfiles/comp_analysis.xml", package="phylobase")
nxml <- nexml_read(nxmlFile)
nxmlEx <- phylo4(nxml)


fmichonneau/phylobase documentation built on Feb. 3, 2024, 2:29 a.m.