Description Usage Arguments Details Value Examples
View source: R/mergeMappedStates2.R
This function renames, merges, or splits mapped states on a tree.
1 | mergeMappedStates2(tree, old.states, new.state, node = NULL)
|
tree |
an object of class "simmap" or "multiSimmap" containing one or more phylogenetic trees with a mapped discrete character |
old.states |
state(s) to rename or merge |
new.state |
name for new state |
node |
a node index, used to specify a subclade of interest |
If node
is specified, only mapped states of descendants edges of that node are modified. This function is based on the similarly named utility function by Liam Revell in phytools
.
An object of class "simmap" or "multiSimmap".
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | library(phytools)
# simulate a mapped tree
set.seed(4)
Q <- matrix(c(-2,1,1,1,-2,1,1,1,-2),3,3)
rownames(Q) <- colnames(Q) <- letters[1:3]
tree <- sim.history(pbtree(n=100,scale=1),Q)
cols <- setNames(c("blue","red","green","orange"),letters[1:4])
# plot the mapping
plot(tree, cols, ftype="i", fsize=0.7)
# split state c to state d within subclade
tree2 <- mergeMappedStates2(tree, "c", "d", 173)
# plot the new mapping
plot(tree2, cols, ftype="i", fsize=0.7)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.