ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

Coloring one edge with multiple trait values

Open EvoLandEco opened this issue 3 years ago • 2 comments
trafficstars

Currently ggtree can color the branches of a tree by assigning values to all the edges or nodes. But in my case, the trait value of each lineage is changing through time during simulation, I would like to know that can ggtree color the branches in this way? This means that each edge might have multiple colors in different time slots.

Below is an illustration, I hope it helps. image

EvoLandEco avatar Nov 23 '21 13:11 EvoLandEco

Maybe you can refer to this

xiangpin avatar Nov 24 '21 01:11 xiangpin

@xiangpin in this example, the trait values are assigned to the respective nodes, the color is changing continuously from one node to another, if I understand it correctly. Here is an example from the diversitree package, can ggtree do something like this?

library(diversitree)

pars <- c(0.1, 0.1, 0.03, 0.03, 0.03, 0.06)
set.seed(1)

phy <- trees(pars,
             "bisse",
             max.taxa = 50,
             max.t = Inf,
             x0 = 0)[[1]]

h <- history.from.sim.discrete(phy, 0:1)
lik <- make.mk2(phy, phy$tip.state)
st.m <- asr.marginal(lik, pars[5:6])

plot(h, phy, main = "Marginal ASR", show.node.state = FALSE)

Created on 2021-11-24 by the reprex package (v2.0.1)

EvoLandEco avatar Nov 24 '21 13:11 EvoLandEco