getClans(tree)
getClips(tree, all=TRUE)
getSlices(tree)
getDiversity(tree, x, norm=TRUE, var.names = NULL, labels="new")
diversity(tree, X)getDiversity computes either the
Shannon Diversity: $H = -\sum_{i=1}^{k}(N_i/N) log(N_i/N), N=\sum_{i=1}^{k} N_i$
or the
Equitability Index: $E = H / log(N)$
where $N_i$ are the sizes of the $k$ largest homogeneous clans of intruders.
If the categories of the data can be separated by an edge of the tree then the E-value will be zero,
and maximum equitability (E=1) is reached if all intruders are in separate clans.
getDiversity computes these Intruder indices for the whole tree, complete clans and complete slices.
Additionally the parsimony scores (p-scores) are reported. The p-score indicates if the leaves contain only one color (p-score=0), if
the the leaves can be separated by a single split (perfect clan, p-score=1) or by a pair of splits (perfect slice, p-score=2).
So far only 2 states are supported (native, intruder), however it is also possible to recode several states
into the native or intruder state using contrasts, for details see section 2 in vignette("phangorn-specials").
Furthermore unknown character states are coded as ambiguous character, which can act either as native or intruder
minimizing the number of clans or changes (in parsimony analysis) needed to describe a tree for given data.
Set attribute labels to "old" for analysis as in Schliep et al. (2010) or to "new" for names which are more intuitive.
diversity returns a data.frame with the parsimony score for each tree and each levels of the variables in X. X has to be a data.frame where each column is a factor and the rownames of X correspond to the tips of the trees.parsimony, Consistency index CI, Retention index RI, phyDatset.seed(111)
tree = rtree(10)
getClans(tree)
getClips(tree, all=TRUE)
getSlices(tree)
set.seed(123)
trees = rmtree(10, 20)
X = matrix(sample(c("red", "blue", "violet"), 100, TRUE, c(.5,.4, .1)), ncol=5,
dimnames=list(paste('t',1:20, sep=""), paste('Var',1:5, sep="_")))
x = phyDat(X, type = "USER", levels = c("red", "blue"), ambiguity="violet")
plot(trees[[1]], "u", tip.color = X[trees[[1]]$tip,1]) # intruders are blue
(divTab <- getDiversity(trees, x, var.names=colnames(X)))
summary(divTab)Run the code above in your browser using DataLab