Hello, Tom.

Here is a bit of code for plotting polymorphic tip states. I think it
should be straightforward to adapt for your purposes.

You'd have to fiddle with the parameters 'x.lim', 'label.offset', and
'adj' to get the spacing right. (It depends on the tree depth etc.)
I'd love to hear of a better way of doing this.

I used this for plotting geographic distributions, which I
reconstructed with Lagrange, but hopefully someone else can help with
how to reconstruct multistate *morphological* data. (Maybe Multistate
in BayesTraits?)

Regards,
Jack Viljoen

### R CODE ###
library(ape)

tr <- 
read.tree(text="(((Strix_aluco:4.2,Asio_otus:4.2):3.1,Athene_noctua:7.3):6.3,Tyto_alba:13.5);")
states <- c("A", "B", "C")
clrs <- c("red", "yellow", "blue")
tip.data <- matrix(c(0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0), nrow=4, byrow=T,
                   dimnames=list(tr$tip.label, states))
tip.data

plot(tr, label.offset=1, cex=1)
for (i in seq_along(states)) {
  x <- which(tip.data[,i]==1)
  y <- apply(tip.data, 1, cumsum)[i, x]
  for (j in seq_along(x)) {
    tiplabels(tip=x[j], pch=22, bg=clrs[i], adj=c(y[j]*0.40, 0.5), cex=1.5)
  }
}
legend("bottomleft", legend=states, pt.bg=clrs, pch=22)
### FINIS ###


> Message: 10
> Date: Wed, 19 Jun 2013 16:48:57 +0000
> From: Tom Wenseleers <tom.wensele...@bio.kuleuven.be>
> To: "r-sig-phylo@r-project.org" <r-sig-phylo@r-project.org>
> Subject: [R-sig-phylo] Representing phylogenies with polymorphisms and
>         reconstruction of ancestral states
> Message-ID:
>         
> <37efc97028f3e44082acc5cbec00563011275...@icts-s-mbx7.luna.kuleuven.be>
>
> Content-Type: text/plain; charset="us-ascii"
>
> Dear all,
>
> I would like to draw a phylogeny with polymorphic states at some of the tips 
> as in the example in attachment (red=presence of one type of chemical 
> compound active as a queen pheromone in different social insects, 
> blue=presence of another type of compound, grey=equivocal maximum parsimony 
> reconstruction - I have up to 6 possible types of compounds which can be 
> present or absent which should all be represented by different colours). Does 
> anyone know if there is any function in R that would allow me to make such a 
> figure in an automated way (eg using packages phytools or diversitree), or 
> how some existing function could be modified to allow plotting such trees? 
> The example in attachment was manually redrawn from output of Mesquite, but 
> the original output of Mesquite looks really ugly, which is why I am looking 
> for another solution... Any thoughts? Also, I was wondering what would be the 
> best method to reconstruct ancestral states in this case? In Mesquite I 
> defined my traits!
  a!
>  s polymorphic, but the reconstructed ancestral states (using unordered max 
> parsimony) are then always monomorphic, whereas I think that polymorphic 
> ancestral states should be allowed. Or would it be better to define the 
> categories of compounds as distinct binary traits, each coded by 0 or 1 (with 
> 1 for it being active as a queen pheromone and 0 for inactive), and then 
> carry out separate maximum parsimony reconstructions on each?
>
> cheers, Tom
> _______________________________________________________________________________________
>
> Prof. Tom Wenseleers
> *      Lab. of Socioecology and Social Evolution
>            Dept. of Biology
>            Zoological Institute
>            K.U.Leuven
>            Naamsestraat 59, box 2466
>            B-3000 Leuven
>            Belgium
> * +32 (0)16 32 39 64 / +32 (0)472 40 45 96
> * tom.wensele...@bio.kuleuven.be
> http://bio.kuleuven.be/ento/wenseleers/twenseleers.htm

_______________________________________________
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