I'm following the next example to generate a phylogenetic tree with the next code
library(ggtreeExtra)
library(ggtree)
library(treeio)
library(ggplot2)
The data are available in: https://github.com/YuLab-SMU/ggtree/tree/master/inst/examples
tree <- read.beast("examples/MCC_FluA_H3.tree")
genotype <- read.table("examples/Genotype.txt", sep="\t")
colnames(genotype) <- sub("\\.$", "", colnames(genotype))
genotype$ID <- row.names(genotype)
dat <- reshape2::melt(genotype, id.vars="ID", variable.name = "type", value.name="genotype", factorsAsStrings=FALSE)
dat$genotype <- unlist(lapply(as.vector(dat$genotype),function(x)ifelse(nchar(x)==0,NA,x)))
now the plot
p <- ggtree(tree) + geom_treescale()
p2 <- p + geom_fruit(data=dat,
geom=geom_tile,
mapping=aes(y=ID, x=type, fill=genotype),
color="white") +
scale_fill_manual(values=c("steelblue", "firebrick", "darkgreen"),
na.translate=FALSE) +
geom_axis_text(angle=-45, hjust=0, size=1.5) +
geom_tiplab(align = TRUE, linesize=0, offset = 6, size=2) +
xlim_tree(xlim=c(0, 36)) +
scale_y_continuous(limits = c(-1, NA))
my problem is with geom_axis_text, it suppose to be part of ggtreeExtra package, nevertheless I have tried to locate the function but I just cant, this what it say:
Error in geom_axis_text(angle = -45, hjust = 0, size = 1.5) :
could not find function "geom_axis_text"
it is part of a different package ? or how to add labels in the x axis of the heatmap created with geom_fruit or other function