Hi,
I am having a problem with the legend order in gheatmap. I have the degree of expression in a trait that is ordinally ordered from -3 to +3. When I plot this, gheatmap assumes that -1 is the lowest value, counts up to -3, then 0, and then starts from 1 to 3 (as you can see in my example).
Here is a reproducible example:
library(geiger)
library(ggplot2)
library(ggtree)
set.seed(12345)
tree <- sim.bdtree(b = 0.1, d = 0, stop = "time", t = 20, seed = 12345)
ptree <- ggtree(tree)
trait.mode <- data.frame(trait = as.factor(sample( -3:3, length(tree$tip.label), replace = T)))
rownames(trait.mode) <- tree$tip.label
gheatmap(ptree,trait.mode, offset =1, width=.05, colnames=F, colnames_offset_y = 8 ) +
scale_fill_viridis_d(option="A", name="Parental\ncare")
I tried to convert the traits to integers but then it complains that I am using a discrete color scale for a continuous trait.
Any Idea how I can fix it?