get_tree_span {castor} R Documentation

## Get min and max distance of any tip to the root.

### Description

Given a rooted phylogenetic tree, calculate the minimum and maximum phylogenetic distance (cumulative branch length) of any tip from the root.

### Usage

```get_tree_span(tree, as_edge_count=FALSE)
```

### Arguments

 `tree` A rooted tree of class "phylo". The root is assumed to be the unique node with no incoming edge. `as_edge_count` Logical, specifying whether distances should be counted in number of edges, rather than cumulative edge length. This is the same as if all edges had length 1.

### Details

If `tree\$edge.length` is missing, then every edge in the tree is assumed to be of length 1. The tree may include multi-furcations as well as mono-furcations (i.e. nodes with only one child). The asymptotic average time complexity of this function is O(Nedges), where Nedges is the number of edges in the tree.

### Value

A named list with the following elements:

 `min_distance` Minimum phylogenetic distance that any of the tips has to the root. `max_distance` Maximum phylogenetic distance that any of the tips has to the root.

### Author(s)

Stilianos Louca

`get_pairwise_distances`

### Examples

```# generate a random tree
Ntips   = 1000
params  = list(birth_rate_intercept=1, death_rate_intercept=0.5)
tree    = generate_random_tree(params, max_tips=Ntips, coalescent=FALSE)\$tree

# calculate min & max tip distances from root
tree_span = get_tree_span(tree)
cat(sprintf("Tip min dist = %g, max dist = %g\n",
tree_span\$min_distance,
tree_span\$max_distance))
```

[Package castor version 1.7.0 Index]