MyNixOS website logo
Description

Phylogenetic Tree Statistics.

Collection of phylogenetic tree statistics, collected throughout the literature. All functions have been written to maximize computation speed. The package includes umbrella functions to calculate all statistics, all balance associated statistics, or all branching time related statistics. Furthermore, the 'treestats' package supports summary statistic calculations on Ltables, provides speed-improved coding of branching times, Ltable conversion and includes algorithms to create intermediately balanced trees. Full description can be found in Janzen (2024) <doi:10.1016/j.ympev.2024.108168>.

CRAN_Status_Badge R-CMD-check codecov.io

Treestats

Measuring properties of phylogenetic trees

The treestats R package contains rapid, C++ based, functions to calculate summary statistics on phylogenies. For some functions (but not all, see below), the phylogenies are required to be ultrametric and/or binary.

Getting started

Installation

To get started, you can either install from CRAN or use the latest version from GitHub:

install.packages("treestats") # install from CRAN

# use the devtools package to install latest version from GitHub:
install.packages("devtools")
devtools::install_github("thijsjanzen/treestats")

Basic usage

Given a tree (for example a simulated tree, as in the code example), you can either access individual statistics, or calculate all currently implemented statistics:

focal_tree   <- ape::rphylo(n = 10, birth = 1, death = 0)
colless_stat <- treestats::colless(focal_tree)
all_stats    <- treestats::calc_all_stats(focal_tree)

List of statistics

The following summary statistics are included:

StatisticInformationNormalizationAssumes Ultrametric treeRequires binary treeReference
area_per_pairTopologyYuleNOYESLima et al., 2020
average_leaf_depthTopologyYuleNOYESShao & Sokal, 1990
avg_ladderTopologyNoneNOYESKendall et al., 2018
avg_vert_depthTopologyNoneNONOHerrada, 2011
b1TopologyTipsNONOShao & Sokal, 1990
b2TopologyYuleNONOShao & Sokal, 1990
betaTopologyNoneNOYESAldous, 1996
blumTopologyNoneNOYESBlum & François, 2006
cherriesTopologyYuleNOYESMcKenzie et al., 1999
collessTopologyYuleNOYESColless, 1982
colless_corrTopologyNoneNOYESHeard, 1992
colless_quadTopologyNoneNOYESBartoszek et al., 2021
crown_ageBranching timesNoneNONO
diameterTopologyNoneNOYESChindelevitch et al., 2021
double_cherriesTopologyNoneNOYESChindelevitch et al., 2021
eigen_centralityTopologyNoneNONOChindelevitch et al., 2021
eigen_centralityWTopology + branch lengthsNoneNONOChindelevitch et al., 2021
ew_collessTopologyNoneNOYESMooers & S. B. Heard, 1997
four_prongTopologyNoneNOYESChindelevitch et al., 2021
gammaBranching timesNoneYESNOPybus & Harvey, 2000
i_statTopologyNoneNOYESFusco & Cronk, 1995
il_numberTopologyTipsNONOKendall et al., 2018
imbalance_stepsTopologyTipsNONOJanzen & Etienne, 2024
j_oneTopologyNoneNOYESLemant et al., 2022
j_statTopology + branch lengthsNoneNONOIzsák & Papp, 2000
laplace_spectrum_aTopology + branch lengthsNoneYESNOLewitus & Morlon, 2016
laplace_spectrum_eTopology + branch lengthsNoneYESNOLewitus & Morlon, 2016
laplace_spectrum_gTopology + branch lengthsNoneYESNOLewitus & Morlon, 2016
laplace_spectrum_pTopology + branch lengthsNoneYESNOLewitus & Morlon, 2016
max_adjTopology + branch lengthsNoneNOYESChindelevitch et al., 2021
max_betweennessTopologyTipsNOYESChindelevitch et al., 2021
max_closenessTopologyTipsNOYESChindelevitch et al., 2021
max_closenessWTopology + branch lengthsNoneNOYESChindelevitch et al., 2021
max_del_widthTopologyTipsNONOColijn & Gardy, 2014
max_depthTopologyTipsNONOColijn & Gardy, 2014
max_ladderTopologyNoneNOYESKendall et al., 2018
max_laplaceTopology + branch lengthsNoneNOYESChindelevitch et al., 2021
max_widthTopologyTipsNONOColijn & Gardy, 2014
mean_branch_lengthTopology + branch lengthsNoneNONOJanzen & Etienne, 2017
mean_branch_length_extTopology + branch lengthsNoneNONOSaulnier et al., 2017
mean_branch_length_intTopology + branch lengthsNoneNONOSaulnier et al., 2017
min_adjTopology + branch lengthsNoneNOYESChindelevitch et al., 2021
min_laplaceTopology + branch lengthsNoneNOYESChindelevitch et al., 2021
mntdTopology + branch lengthsNoneNONOWebb et al., 2002
mpdTopology + branch lengthsTipsNONOWebb et al., 2002
mw_over_mdTopologyNoneNONOColijn & Gardy, 2014
nltt_baseBranching timesNoneYESNOJanzen et al., 2015
number_of_lineagesTopology + branch lengthsNoneNONO
phylogenetic_divTopology + branch lengthsNoneNONOFaith, 1992
pigot_rhoBranching timesNoneYESNOPigot et al., 2010
pitchforksTopologyTipsNONOKendall et al., 2018
psvTopology + branch lengthsTipsNONOHelmus et al., 2007
rogersTopologyTipsNOYESRogers, 1996
root_imbalanceTopologyNoneNOYESGuyer et al., 1993
rquartetTopologyYuleNONOCoronado et al., 2019
sackinTopologyYuleNOYESSackin, 1972
stairsTopologyNoneNOYESNorström et al., 2012
stairs2TopologyNoneNOYESNorström et al., 2012
symmetry_nodesTopologyTipsNOYESKersting & Fischer, 2021
tot_cophTopologyYuleNOYESMir et al., 2013
tot_internal_pathTopologyNoneNONOKnuth, 1997
tot_pathTopologyNoneNOYESColijn & Gardy, 2014
tree_heightBranching timesNoneNONO
treenessTopology + branch lengthsNoneNONOAstolfi & Zonta-Sgaramella, 1984
var_branch_lengthTopology + branch lengthsNoneNONOSaulnier et al., 2017
var_branch_length_extTopology + branch lengthsNoneNONOSaulnier et al., 2017
var_branch_length_intTopology + branch lengthsNoneNONOSaulnier et al., 2017
var_depthTopologyYuleNONOCoronado et al., 2020
vpdTopology + branch lengthsNoneNONOWebb et al., 2002
wienerTopology + branch lengthsNoneNOYESChindelevitch et al., 2021

Rcpp

For all of these statistics, the package provides Rcpp versions that are much, much faster than their R sister functions. Furthermore, some additional functions have been improved as well:

  • ape::branching.times
  • DDD::phylo2L
  • DDD::L2phylo

C++ Library

For the Rcpp improved summary statistics (excluding statistics that rely on the calculation of eigen values, as these rely on the Rcpp independent Eigen code), R independent C++ code is provided in the inst/include folder. These can be independently linked by adding the treestats package in the DESCRIPTION in both the LinkingTo and Depends fields. Then, in your package, you can also calculate these functions.

Please note that for all functions, there are two versions available: 1) based on input of a phylo object, which is typically one 2-column matrix containing all edges, and a vector containing the edge lengths (depending on which information is required to calculate the statistic). 2) based on input of an Ltable (Lineage table), which is a 4-column matrix containing information on each species, being 1) birth time, 2) parent species, 3) species label and 4) death time (or -1 if extant).

Ltable input can be useful when summary statistics are required for more complicated simulation models.

Metadata

Version

1.70.5

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows