View source: R/parsimonyNumber.R
parsimonyNumber | R Documentation |
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.
parsimonyNumber(phylo, clusters = rep(1, length(phylo$tip.label)))
phylo |
phylogenetic tree, class |
clusters |
the vector of the clusters of the tips. Default to all the tips in one single cluster. |
This function does a recursion up the tree.
The function extract.parsimonyNumber
gives the result sought for
any subtree.
The matrix of costs of the states (number of shifts) is also required, it is
computed by function parsimonyCost
.
an object of S3 class "parsimonyNumber
" with:
a (ntaxa + Nnode) x (nclus) matrix of locally parsimonious solutions starting from a cluster k at a given node
an object of class "parsimonyCost
",
result of function parsimonyCost
.
extract.parsimonyNumber
, parsimonyCost
,
enumerate_parsimony
, partitionsNumber
,
equivalent_shifts
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").
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.