Function which takes an object of class phylo and outputs the vector for the Kendall Colijn metric. The elements of the vector are numeric if return.lambda.function=FALSE (default), and otherwise they are functions of lambda.

treeVec(
  tree,
  lambda = 0,
  return.lambda.function = FALSE,
  emphasise.tips = NULL,
  emphasise.weight = 2
)

Arguments

tree

an object of the class phylo

lambda

a number in [0,1] which specifies the extent to which topology (default, with lambda=0) or branch lengths (lambda=1) are emphasised. This argument is ignored if return.lambda.function=TRUE.

return.lambda.function

If true, a function that can be invoked with different lambda values is returned. This function returns the vector of metric values for the given lambda.

emphasise.tips

an optional list of tips whose entries in the tree vector should be emphasised. Defaults to NULL.

emphasise.weight

applicable only if a list is supplied to emphasise.tips, this value (default 2) is the number by which vector entries corresponding to those tips are emphasised.

Value

The vector of values according to the metric, or a function that produces the vector given a value of lambda.

Author

Jacob Almagro-Garcia nativecoder@gmail.com

Michelle Kendall michelle.louise.kendall@gmail.com

Examples


## generate a random tree
tree <- rtree(6)
## topological vector of mrca distances from root:
treeVec(tree)
#>  [1] 2 0 1 4 3 0 1 2 2 0 0 0 1 1 3 1 1 1 1 1 1
## vector of mrca distances from root when lambda=0.5:
treeVec(tree,0.5)
#>  [1] 1.6950163 0.0000000 0.8111938 3.2935701 2.4977981 0.0000000 0.8111938
#>  [8] 1.6950163 1.6950163 0.0000000 0.0000000 0.0000000 0.8111938 0.8111938
#> [15] 2.4977981 0.9185741 0.7899246 0.6847264 0.5418258 0.9862842 0.5838880
## vector of mrca distances as a function of lambda:
vecAsFunction <- treeVec(tree,return.lambda.function=TRUE)
## evaluate the vector at lambda=0.5:
vecAsFunction(0.5)
#>  [1] 1.6950163 0.0000000 0.8111938 3.2935701 2.4977981 0.0000000 0.8111938
#>  [8] 1.6950163 1.6950163 0.0000000 0.0000000 0.0000000 0.8111938 0.8111938
#> [15] 2.4977981 0.9185741 0.7899246 0.6847264 0.5418258 0.9862842 0.5838880