taxo_distance: Compute the phylogenetic distance between two taxa

View source: R/distance.R

taxo_distanceR Documentation

Compute the phylogenetic distance between two taxa

Description

Given two taxon names, retrieves their lineages from The Taxonomicon and computes a taxonomic distance based on the depth of their most recent common ancestor (MRCA):

Usage

taxo_distance(taxon_a, taxon_b, verbose = FALSE)

Arguments

taxon_a

A character string giving the first taxon name.

taxon_b

A character string giving the second taxon name.

verbose

Logical. If TRUE, prints progress messages. Default FALSE.

Details

d(A, B) = \frac{1}{\text{depth}(\text{MRCA}(A,B))}

The deeper the shared ancestor, the smaller (closer to zero) the distance. This metric ensures that taxa diverging at the same node are always equidistant from any third taxon, regardless of lineage depth differences below the split.

Value

A named list of class "taxodist_result" with the following elements:

distance

Numeric. The distance between the two taxa. Returns 0 if one taxon is an ancestor of the other.

mrca

Character. The name of the most recent common ancestor.

mrca_depth

Integer. The depth of the MRCA node.

depth_a

Integer. The lineage depth of taxon A.

depth_b

Integer. The lineage depth of taxon B.

taxon_a

Character. Name of the first taxon.

taxon_b

Character. Name of the second taxon.

Returns NULL if either taxon cannot be found.

References

Brands, S.J. (1989 onwards). Systema Naturae 2000. Amsterdam, The Netherlands. Retrieved from The Taxonomicon, http://taxonomicon.taxonomy.nl.

See Also

mrca(), distance_matrix(), get_lineage()

Examples


# Distance between two theropods
taxo_distance("Tyrannosaurus", "Velociraptor")

# Distance between very distantly related taxa
taxo_distance("Tyrannosaurus", "Quercus")

# Distance between two oviraptorid genera
taxo_distance("Nomingia", "Huanansaurus")


taxodist documentation built on May 6, 2026, 1:06 a.m.