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:

StatisticInformationFischerNormalizationAssumes Ultrametric treeRequires binary treeAssumes rooted treeSensitive to root positionReference
area_per_pairTopologyShapeYuleNOYESYESYESLima et al., 2020
average_leaf_depthTopologyImbalanceYuleNOYESYESYESShao & Sokal, 1990
avg_ladderTopologyShapeNoneNOYESYESYESKendall et al., 2018
avg_vert_depthTopologyImbalanceNoneNONOYESYESColijn & Gardy, 2014
b1TopologyBalanceTipsNONOYESYESShao & Sokal, 1990
b2TopologyBalanceYuleNONOYESYESShao & Sokal, 1990
betaTopologyNo indexNoneNOYESYESYESAldous, 1996
blumTopologyImbalanceNoneNOYESYESYESBlum & François, 2006
cherriesTopologyShapeYuleNOYESNOYESMcKenzie et al., 1999
collessTopologyImbalanceYuleNOYESYESYESColless, 1982
colless_corrTopologyImbalanceNoneNOYESYESYESHeard, 1992
colless_quadTopologyImbalanceNoneNOYESYESYESBartoszek et al., 2021
crown_ageBranching timesNo indexNoneNONOYESYES
diameterTopologyShapeNoneNOYESYESYESChindelevitch et al., 2021
double_cherriesTopologyShapeNoneNOYESNOYESChindelevitch et al., 2021
eigen_centralityTopologyNo indexNoneNONONOYESChindelevitch et al., 2021
eigen_centralityWTopology + branch lengthsNo indexNoneNONONOYESChindelevitch et al., 2021
ew_collessTopologyImbalanceNoneNOYESYESYESMooers & S. B. Heard, 1997
four_prongTopologyShapeNoneNOYESNOYESChindelevitch et al., 2021
gammaBranching timesNo indexNoneYESNOYESYESPybus & Harvey, 2000
i_statTopologyImbalanceNoneNOYESYESYESFusco & Cronk, 1995
il_numberTopologyShapeTipsNONONOYESKendall et al., 2018
imbalance_stepsTopologyNo indexTipsNONOYESYESJanzen & Etienne, 2024
j_oneTopologyNo indexNoneNOYESYESYESLemant et al., 2022
j_statTopology + branch lengthsNo indexNoneNONONONOIzsák & Papp, 2000
laplace_spectrum_aTopology + branch lengthsNo indexNoneYESNONOYESLewitus & Morlon, 2016
laplace_spectrum_eTopology + branch lengthsNo indexNoneYESNONOYESLewitus & Morlon, 2016
laplace_spectrum_gTopology + branch lengthsNo indexNoneYESNONOYESLewitus & Morlon, 2016
laplace_spectrum_pTopology + branch lengthsNo indexNoneYESNONOYESLewitus & Morlon, 2016
max_adjTopology + branch lengthsNo indexNoneNOYESNOYESChindelevitch et al., 2021
max_betweennessTopologyShapeTipsNOYESYESYESChindelevitch et al., 2021
max_closenessTopologyShapeTipsNOYESNOSmallChindelevitch et al., 2021
max_closenessWTopology + branch lengthsShapeNoneNOYESNOSmallChindelevitch et al., 2021
max_del_widthTopologyShapeTipsNONOYESYESColijn & Gardy, 2014
max_depthTopologyImbalanceTipsNONOYESYESColijn & Gardy, 2014
max_ladderTopologyShapeNoneNOYESNOYESKendall et al., 2018
max_laplaceTopology + branch lengthsNo indexNoneNOYESNOYESChindelevitch et al., 2021
max_widthTopologyBalanceTipsNONOYESYESColijn & Gardy, 2014
mean_branch_lengthTopology + branch lengthsNo indexNoneNONONOYESJanzen & Etienne, 2017
mean_branch_length_extTopology + branch lengthsNo indexNoneNONONONOSaulnier et al., 2017
mean_branch_length_intTopology + branch lengthsNo indexNoneNONONOYESSaulnier et al., 2017
min_adjTopology + branch lengthsNo indexNoneNOYESNOYESChindelevitch et al., 2021
min_laplaceTopology + branch lengthsNo indexNoneNOYESNOYESChindelevitch et al., 2021
mntdTopology + branch lengthsNo indexNoneNONONONOWebb et al., 2002
mpdTopology + branch lengthsNo indexTipsNONONONOWebb et al., 2002
mw_over_mdTopologyBalanceNoneNONOYESYESColijn & Gardy, 2014
nltt_baseBranching timesNo indexNoneYESNOYESYESJanzen et al., 2015
number_of_lineagesTopology + branch lengthsNo indexNoneNONONONO
phylogenetic_divTopology + branch lengthsNo indexNoneNONOYESYESFaith, 1992
pigot_rhoBranching timesNo indexNoneYESNOYESYESPigot et al., 2010
pitchforksTopologyShapeTipsNONONOYESKendall et al., 2018
psvTopology + branch lengthsNo indexTipsNONONONOHelmus et al., 2007
rogersTopologyImbalanceTipsNOYESNOYESRogers, 1996
root_imbalanceTopologyShapeNoneNOYESYESYESGuyer et al., 1993
rquartetTopologyBalanceYuleNONOYESYESCoronado et al., 2019
sackinTopologyImbalanceYuleNOYESYESYESSackin, 1972
stairsTopologyImbalanceNoneNOYESYESYESNorström et al., 2012
stairs2TopologyBalanceNoneNOYESYESYESNorström et al., 2012
symmetry_nodesTopologyImbalanceTipsNOYESYESYESKersting & Fischer, 2021
tot_cophTopologyImbalanceYuleNOYESYESYESMir et al., 2013
tot_internal_pathTopologyImbalanceNoneNONOYESYESKnuth, 1997
tot_pathTopologyImbalanceNoneNOYESYESYESColijn & Gardy, 2014
tree_heightBranching timesNo indexNoneNONOYESYES
treenessTopology + branch lengthsNo indexNoneNONONOYESAstolfi & Zonta-Sgaramella, 1984
var_branch_lengthTopology + branch lengthsNo indexNoneNONONOYESSaulnier et al., 2017
var_branch_length_extTopology + branch lengthsNo indexNoneNONONOYESSaulnier et al., 2017
var_branch_length_intTopology + branch lengthsNo indexNoneNONONOYESSaulnier et al., 2017
var_depthTopologyImbalanceYuleNONOYESYESCoronado et al., 2020
vpdTopology + branch lengthsNo indexNoneNONONONOWebb et al., 2002
wienerTopology + branch lengthsShapeNoneNOYESNOYESChindelevitch 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.8

License

Unknown

Platforms (78)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • 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-linux
  • 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-uefi
  • x86_64-windows