densityMap {phytools} | R Documentation |
Plot posterior density of stochastic mapping on a tree
Description
Visualize posterior probability density from stochastic mapping using a color gradient on the tree.
Usage
densityMap(trees, res=100, fsize=NULL, ftype=NULL, lwd=3, check=FALSE,
legend=NULL, outline=FALSE, type="phylogram", direction="rightwards",
plot=TRUE, ...)
## S3 method for class 'densityMap'
plot(x, ...)
Arguments
trees |
set of phylogenetic trees in a modified |
res |
resolution for gradient plotting. Larger numbers indicate a finer (smoother) gradient. |
fsize |
relative font size - can be a vector with the second element giving the font size for the legend. |
ftype |
font type - see options in |
lwd |
line width for branches. If a vector of two elements is supplied, the second element will be taken to be the desired width of the legend bar. |
check |
check to make sure that the topology and branch lengths of all phylogenies in |
legend |
if |
outline |
logical value indicating whether or not to outline the branches of the tree in black. |
type |
type of plot desired. Options are |
plot |
logical value indicating whether or not to plot the tree. If |
direction |
plotting direction for |
x |
for |
... |
optional arguments for |
Details
Function plots a tree with the posterior density for a mapped character from stochastic character mapping on the tree. Since the mapped value is the probability of being in state "1", only binary [0,1] characters are allowed.
Value
Plots a tree and returns an object of class "densityMap"
invisibly.
Author(s)
Liam Revell liam.revell@umb.edu
References
Bollback, J. P. (2006) Stochastic character mapping of discrete traits on phylogenies. BMC Bioinformatics, 7, 88.
Huelsenbeck, J. P., R. Neilsen, and J. P. Bollback (2003) Stochastic mapping of morphological characters. Systematic Biology, 52, 131-138.
Revell, L. J. (2013) Two new graphical methods for mapping trait evolution on phylogenies. Methods in Ecology and Evolution, 4, 754-759.
Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). PeerJ, 12, e16505.
See Also
make.simmap
, plotSimmap
, read.simmap
Examples
## Not run:
## load tree and data from Revell & Collar (2009)
data(sunfish.tree)
data(sunfish.data)
## extract discrete character (feeding mode)
fmode<-setNames(sunfish.data$feeding.mode,
rownames(sunfish.data))
## do stochastic mapping
smap.trees<-make.simmap(sunfish.tree,fmode,model="ER",
nsim=100)
## compute "densityMap" object
sunfish.dmap<-densityMap(smap.trees,plot=FALSE,
res=50) ## res should be higher
## plot density map
plot(sunfish.dmap,lwd=5,outline=TRUE)
par(mar=c(5.1,4.1,4.1,2.1)) ## reset margins to default
## End(Not run)