I'm having trouble with labeling single tips in my tree with ggtree. I'm trying to highlight and label nodes from a tree with geom_hilight and geom_cladelabel. This seems to work fine with nodes that have more than 1 tree tip, but when I try to label a single tip, I receive a warning message and the tip doesn't get labeled.
Example:
library(dplyr)
library(ggtree)
library(dplyr)
library(ggtree)
#Create tree
set.seed(123)
tree <- rtree(30)
ggtree(tree)
#Highlight and label clade
ggtree(tree) + geom_text(aes(label=node)) + geom_tiplab(size=3, offset=0.1) +
geom_hilight(node=3, fill="steelblue", alpha=0.5) +
geom_hilight(node=38, fill="pink", alpha=0.5) +
geom_cladelabel(node=38, label="clade 2", align=T,
color='black', fontsize=4)
As you can see, I'm able to highlight both node 38 and 3 with geom_hilight. I also labeled node 38 with the text "Clade 2" with geom_cladelabel.
However, when I try to label node 3 with geom_cladelabel, I receive a warning message:
#Highlight and label single tip
ggtree(tree) + geom_text(aes(label=node)) + geom_tiplab(size=3, offset=0.1) +
geom_hilight(node=3, fill="steelblue", alpha=0.5) +
geom_hilight(node=38, fill="pink", alpha=0.5) +
geom_cladelabel(node=3, label="clade 1", align=T,
color='black', fontsize=4) +
geom_cladelabel(node=38, label="clade 2", align=T,
color='black', fontsize=4)
Warning messages:
1: In max(sp.df$x, na.rm = TRUE) :
no non-missing arguments to max; returning -Inf
2: In min(y) : no non-missing arguments to min; returning Inf
3: In max(y) : no non-missing arguments to max; returning -Inf
4: In max(sp.df$x, na.rm = TRUE) :
no non-missing arguments to max; returning -Inf
5: In min(y) : no non-missing arguments to min; returning Inf
6: In max(y) : no non-missing arguments to max; returning -Inf
The line from the clade label ends up covering the entire tree for some reason:
Is there a way that I can label a single tip in the same fashion as clade_geomlabel does for regular nodes?
Any help is appreciated.