I was just corresponding with a phytools user & essentially the lack
of an argument node.col
in the function
phylomorphospace3d
was broached.
Why this option doesn't exist, I couldn't tell you; however it is relatively easy to circumvent because the function invisibly returns a list of functions which can be used to plot points, lines, planes, etc., back in the original (simulated) space.
Here's a quick example, using simulated data:
library(phytools)
tree ## our tree
##
## Phylogenetic tree with 26 tips and 25 internal nodes.
##
## Tip labels:
## A, B, C, D, E, F, ...
##
## Rooted; includes branch lengths.
X ## our data
## [,1] [,2] [,3]
## A -2.84172235 1.148037248 1.64782403
## B -2.05052328 1.431708869 1.15202298
## C -1.24686168 1.946696167 1.54897262
## D -0.52310503 0.573110584 0.46436125
## E -0.55578283 0.813448906 0.40254794
## F -0.51150759 1.733066759 1.49429840
## G 0.53936198 1.816801753 1.86050506
## H 0.01234429 2.302339855 2.63078614
## I -0.01684737 1.810997083 2.22857705
## J 1.32317051 2.492348110 0.55660832
## K 0.39032083 1.138053408 -0.42215854
## L 1.35224610 0.701773929 -0.73233992
## M 0.06642055 2.393143196 1.67769111
## N 0.53170462 2.387858206 1.07395647
## O 1.33893651 1.869361233 1.18002858
## P 0.16788769 1.722551818 0.03908209
## Q 0.72826260 0.591128118 1.23662094
## R 0.79698877 1.310841641 1.38182879
## S 0.08976056 1.727227579 2.10565084
## T 1.37506375 -0.551729936 -1.73123720
## U -1.09244120 0.960226117 -1.01694632
## V -0.75692309 -0.002878853 -1.02230472
## W -0.53535698 -0.168545803 -1.33846396
## X -0.26869690 -0.241183840 -1.14188545
## Y 0.19315024 0.282576551 -0.89620379
## Z -0.56460363 -0.613852876 0.98093216
y ## our character we want to map on the tips
## A B C D E F G H I J K L M N O P Q R
## "c" "c" "b" "b" "b" "a" "a" "b" "b" "c" "c" "b" "c" "c" "c" "a" "c" "b"
## S T U V W X Y Z
## "b" "b" "c" "b" "c" "c" "c" "c"
tip.col<-y
tip.col[tip.col=="a"]<-"red"
tip.col[tip.col=="b"]<-"blue"
tip.col[tip.col=="c"]<-"yellow"
obj<-phylomorphospace3d(tree,X,method="static")
obj$points3d(X,cex=1.4,pch=21,bg=tip.col[rownames(X)])
That's it.
The tree & data were simulated as follows:
X<-fastBM(tree,nsim=3)
Q<-matrix(c(-1,1,0,1,-2,1,0,1,-1),3,3)
rownames(Q)<-colnames(Q)<-c("a","b","c")
y<-sim.history(tree,Q)$states
Dear Liam,
ReplyDeleteI've been playing around with the function phylomorphospace3d and my data and everything seems to work fine. However, I've been struggling when trying to remove the individual labels of each data point (it's difficult to interpret the phylomorphospace because all the labels overlap, so it would be great just to remove them). After checking the documentation, I applied the ftype='off' control parameter without any success, so I would really appreciate some help! thanks a lot!!
Hi Tom.
DeleteRemoving tip labels for method="dynamic" (the default, which uses rgl internally) can be done with the argument control=list(ftype="off").
Removing tip labels in method="static" is not possible in the current CRAN version; however I just pushed a fix to GitHub. You can install this version from GitHub using devtools & it works the same way as in the dynamic plotting option.
- Liam
Thanks a lot for your help Liam that was really helpful!
Deletebest wishes
Liam - can we change the tip colors in method="dynamic"? I can't seem to get it to work.
ReplyDeleteWe see the coloring pages for kids of a question in light of the fact that the light falling on it contains an indistinguishable colors from the protest.
ReplyDelete