Learn R Programming

dispRity (version 1.5.0)

nodes.coordinates: Nodes coordinates

Description

Calculates ancestral nodes coordinates in a format that can be passed to ancestral.dist

Usage

nodes.coordinates(matrix, tree, full = TRUE)

Arguments

matrix

The matrix on which centroids will be applied

tree

A tree topology of class "phylo".

full

Whether to get the centroids for all ancestors down to the root (TRUE - default) or only the direct ancestors (FALSE)

Value

A matrix if full = FALSE or a list of matrices if full = TRUE.

See Also

ancestral.dist, dispRity.metric, dispRity, get.ancestors

Examples

Run this code
# NOT RUN {
## A random matrix
matrix <- matrix(rnorm(90), 9, 10)
## A random treee with node labels
tree <- rtree(5) ; tree$node.label <- paste0("n", 1:4)
## Adding the tip and node names to the matris
rownames(matrix) <- c(tree$tip.label, tree$node.label)

## Calculating the direct ancestral nodes
direct_anc_centroids <- nodes.coordinates(matrix, tree, full = FALSE)
## Calculating all the ancestral nodes
all_anc_centroids <- nodes.coordinates(matrix, tree, full = TRUE)

## Calculating the distances from the direct ancestral nodes
ancestral.dist(matrix, nodes.coords = direct_anc_centroids)
## Calculating the distances from all the ancestral nodes
ancestral.dist(matrix, nodes.coords = all_anc_centroids)

# }

Run the code above in your browser using DataLab