parsimonyNumber: Number of equivalent parsimonious allocations.

View source: R/parsimonyNumber.R

parsimonyNumberR Documentation

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.

Details

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.

Value

an object of S3 class "parsimonyNumber" with:

nbrReconstructions

a (ntaxa + Nnode) x (nclus) matrix of locally parsimonious solutions starting from a cluster k at a given node

costReconstructions

an object of class "parsimonyCost", result of function parsimonyCost.

See Also

extract.parsimonyNumber, parsimonyCost, enumerate_parsimony, partitionsNumber, equivalent_shifts

Examples

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"). 


pbastide/PhylogeneticEM documentation built on Feb. 12, 2024, 1:27 a.m.