Hi all,

I would like to use the results of make.simmap to plot the edges of a tree
by their most likely state. (Because my tree is really large and plotting
pie charts at the nodes gets really polluted.)

So first I took $ace from the results to describe.simmap and added a column
for the most likely state, and another column for the color for plotting:

> head(ace.max.lik)
     CL    EL     M     P SL maxlik            col
6621  0 0.000 0.002 0.998  0      P darkgoldenrod3
6622  0 0.000 0.001 0.999  0      P darkgoldenrod3
6623  0 0.000 0.007 0.993  0      P darkgoldenrod3
6624  0 0.000 0.004 0.996  0      P darkgoldenrod3
6625  0 0.000 0.001 0.999  0      P darkgoldenrod3
6626  0 0.001 0.020 0.979  0      P darkgoldenrod3

And I separately did that for the tips. (Which I also estimated, since they
had uncertainty in the original data):

                         CL EL M P SL maxlik            col
Rhea_americana                  0.000        0.000       0.000       1.000
       0.000      P darkgoldenrod3
Rhea_pennata                    0.000        0.000       0.008       0.992
       0.000      P darkgoldenrod3
Casuarius_casuarius             0.000        0.004       0.074       0.922
       0.000      P darkgoldenrod3
Casuarius_bennetti              0.000        0.010       0.132       0.858
       0.000      P darkgoldenrod3
Dromaius_novaehollandiae        0.001        0.000       0.045       0.953
       0.001      P darkgoldenrod3
Apteryx_owenii                  0.000        0.000       0.995       0.005
       0.000      M           blue

Then I tried to plot the edges by color using ape, putting the tips in
front of the internal nodes because that's the typical order of tree$edges:

plot.phylo(x=m.ard[[1]],cex=0.2,edge.width=0.01,type='fan',
           edge.lty=3,edge.color=c(tip.max.lik$col, ace.max.lik$col))

It plots a beautiful plot, by the colors are mismatched to the edges. I
also noticed that results of simmap have one extra edge than the tree
itself:

> nrow(md.ard$ace)
[1] 13239

> nrow(m.ard[[1]]$edge)
[1] 13238

I suspect that's that one extra edge that's causing the mismatch, but I
can't figure out where it's coming from, or how to fix it. Any tips or
workarounds to accomplish this task, which I might be overcomplicating?

PS: I'm well aware that it's a bad idea to "flatten" the likelihoods of
different states into a single most likely state, and I absolutely do not
plan to discard that uncertainty. I just want to plot a simpler tree for
visualization.

Thanks!

-Rafa

*--*
*Rafael S. Marcondes, Ph.D.*
*https://www.rafaelmarcondes.com/ <https://www.rafaelmarcondes.com/>*
Faculty Fellow in EEB
Department of BioSciences
Rice University
Houston TX 77005

Pronouns: he/him


*"Eu quase que nada não sei. Mas desconfio de muita coisa"*
*"I almost don't know nothing. But I suspect many things"*
  -João Guimarães Rosa, Brazilian novelist
(Portuguese original and free English translation by me)

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-phylo mailing list - [email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/[email protected]/

Reply via email to