Marina,
I actually wrote a function to do this the other day. Hope it's helpful:

densiMap <- function(simmap.trees, pal=rainbow, alpha=10, ...){
# Palette is the color palette to draw from, alpha is the transparency of each plot. ... passed to plotSimmap.
  states <- unique(names(unlist(simmap.trees[[1]]$maps)))
  nstates <- length(states)
  makeTransparent <- function (someColor, alpha = 10) {
    newColor <- col2rgb(someColor)
    apply(newColor, 2, function(curcoldata) {
rgb(red = curcoldata[1], green = curcoldata[2], blue = curcoldata[3],
          alpha = alpha, maxColorValue = 255)
    })
  }
  palC <- setNames(pal(nstates), states)
  plotSimmap(simmap.trees[[1]], colors=makeTransparent(palC,alpha), ...)
dum <- lapply(2:length(simmap.trees), function(x) plotSimmap(simmap.trees[[x]], colors=makeTransparent(palC,alpha), add=TRUE,...))
}

# example
require(geiger)
require(phytools)
# Simulate a tree
tree <- sim.bdtree(1, d=0, stop="taxa", n=200)
# Simulate a Q-matrix
qq <- matrix(runif(25, 0, 0.5), ncol=5, nrow=5)
diag(qq) <- apply(qq, 1, sum)*-1
qq[,1] <- qq[,1]-apply(qq,1, sum)
# Simulate some data
dat <- sim.char(tree, qq, model="discrete", n=1)[,,1]
#Generate simmap trees
simmap.trees <- make.simmap(tree, dat, model="ARD", nsim=50)
# Plot
densiMap(simmap.trees, ftype="off", fsize=0.25)


On 05/06/2015 12:29 PM, Marina Strelin wrote:
Hi!

I used phytools to perform a stochastic character mapping on a list of
phylogenetic trees (make.simmap function). Does phytools include a function
somehow analogous to the densiTree function of the R package phangorn that
allows superimposing in a single plot the graphical outputs of the
stochastic character mapping I obtained for different trees?

Thanks in advance for answering my question,

Marina

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Reply via email to