Dear r-sig-phylo members,

I have a question about the usage of gradients in plot.phylo.

I thought it would be useful to visualize change on my trees by plotting gradients from each tip/node to each tip/node. However, plot.phylo seems to only want to plot uniform colors, and not gradients....

Here is my code (I know it's messy, but since I'm still working on it is clearer for me):

library(ape)
library(plotrix)

rtree(15) -> tree

rnorm(15, mean = 0.5, sd = 0.15) -> data

ace(data, tree) -> results

data <- append(data,results$ace)

names(data) <- NULL

create.gradient <- function(i){
colorgrad01<-color.scale(seq(0,1,by=0.01), extremes=c("red","blue"))
tree$edge[i,1] -> x
tree$edge[i,2] -> y
print(x)
print(y)
data[x] -> z
data[y] -> z2
round(z, digits = 2) -> z
round(z2, digits = 2) -> z2
z*100 -> z
z2*100 -> z2
print(z)
print(z2)
colorgrad<-colorgrad01[z:z2]
colorgrad
}
out <- lapply(1:nrow(tree$edge), create.gradient)

so now all gradients for each of the 28 individuals are stored in the object out. Then I try to plot it:

plot.phylo(tree, edge.color=c(out4[[1]], out4[[2]], out4[[3]], out4[[5]], out4[[6]], out4[[7]], out4[[8]], out4[[9]], out4[[10]], out4[[11]], out4[[12]], out4[[13]], out4[[14]], out4[[15]], out4[[16]], out4[[17]], out4[[18]], out4[[19]], out4[[20]], out4[[21]], out4[[22]], out4[[23]], out4[[24]], out4[[25]], out4[[26]], out4[[27]], out4[[28]]), edge.width=5)

It plots fine, but I don't see the gradients, but just uniform colors across the branches. I think it just takes the first color value of each gradient? So - is it impossible to do this with plot.phylo? Or am I overlooking something...?

Thanks!

Annemarie

--
Annemarie Verkerk, MA
Evolutionary Processes in Language and Culture (PhD student)
Max Planck Institute for Psycholinguistics
P.O. Box 310, 6500AH Nijmegen, The Netherlands
+31 (0)24 3521 185
http://www.mpi.nl/research/research-projects/evolutionary-processes

_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo

Reply via email to