Learn R Programming

PhylogeneticEM (version 1.0.0)

parsimonyNumber: Number of equivalent parsimonious allocations.

Description

parsimonyNumber aims at finding the number of equivalent allocations of the shifts on the tree, i.e allocations that are parsimonious and compatible with a given clustering of the tips.

Usage

parsimonyNumber(phylo, clusters = rep(1, length(phylo$tip.label)))

Arguments

phylo
phylogenetic tree, class phylo.
clusters
the vector of the clusters of the tips. Default to all the tips in one single cluster.

Value

an object of S3 class "parsimonyNumber" with:

Details

This function does a recursion up the tree. The function extract.parsimonyNumber gives the result seeked for any subtree. The matrix of costs of the states (number of shifts) is also required, it is computed by function parsimonyCost.

See Also

extract.parsimonyNumber, parsimonyCost, enumerate_parsimony, partitionsNumber, equivalent_shifts

Examples

Run this code
tree <- read.tree(text="(((0,1),2),2);")
plot(tree); nodelabels()
clusters <- c(0, 1, 2, 2)
n_sols <- parsimonyNumber(tree, clusters)
n_sols

## Extract the number of parsimonious solutions at the root
extract(n_sols)

## Extract the cost of the solutions from the root
extract(n_sols, what = "cost")
extract(parsimonyCost(tree, clusters)) # same, more efficient

## Extract for the sub-tree below node 7
extract(n_sols, 7) # Result: 2 (the ancestral state is either "0" or "1"). 

Run the code above in your browser using DataLab