clade_dist: Pairwise distances among clades or nodes

View source: R/ps_diversity.R

clade_distR Documentation

Pairwise distances among clades or nodes

Description

This function runs ape::dist.nodes() with some additional filtering and sorting. By default, it returns distances between every pair of non-nested clades, i.e. every pair of collateral (non-lineal) nodes including terminals and internal nodes.

Usage

clade_dist(tree, lineal = FALSE, edges = TRUE)

Arguments

tree

A phylogeny of class "phylo".

lineal

Logical indicating whether to retain distances for pairs of nodes that are lineal ancestors/descendants. If FALSE (the default), these are set to NA, retaining values only for node pairs that are collateral kin.

edges

Logical indicating whether to return a distance matrix with a row for every edge in tree. If TRUE (the default), rows/columns of the result correspond to tree$edge. If FALSE, rows/columns correspond to nodes as in ape::dist.nodes().

Value

A matrix of pairwise distances between nodes.

Examples

clade_dist(ape::rtree(10))

phylospatial documentation built on June 8, 2025, 1:14 p.m.