ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

tutorial: Chapter10.3

Open Tsingsjeen opened this issue 2 years ago • 2 comments

Hi When I am running the tutorial of: https://yulab-smu.top/treedata-book/chapter10.html, chapter 10.3, I met a problem shown:

Error in structure(list(node = node, fill = fill, alpha = alpha, extend = extend, : argument "node" is missing, with no default

Following the tutorial, the nodedf contains nodes, which were processed. But still reporting node missing.......... Do you know what happened? and the attached was same with the tutorial

which can be displayed with high light using ggtree.

nodeids <- nodeid(tree, tree$node.label[nchar(tree$node.label)>4]) nodedf <- data.frame(node=nodeids) nodelab <- gsub("[\.0-9]", "", tree$node.label[nchar(tree$node.label)>4])

The layers of clade and hightlight

poslist <- c(1.6, 1.4, 1.6, 0.8, 0.1, 0.25, 1.6, 1.6, 1.2, 0.4, 1.2, 1.8, 0.3, 0.8, 0.4, 0.3, 0.4, 0.4, 0.4, 0.6, 0.3, 0.4, 0.3)

labdf <- data.frame(node=nodeids, label=nodelab, pos=poslist)

The circular layout tree.

p <- ggtree(tree, layout="fan", size=0.15, open.angle=5) + geom_hilight(data=nodedf, mapping=aes(node=node), extendto=6.8, alpha=0.3, fill="grey", color="grey50", size=0.05) + geom_cladelab(data=labdf, mapping=aes(node=node, label=label, offset.text=pos), hjust=0.5, angle="auto", barsize=NA, horizontal=FALSE, fontsize=1.4, fontface="italic" )

Tsingsjeen avatar Dec 29 '21 11:12 Tsingsjeen

Which version of ggtree are you using? The aesthetic mapping of geom_hilight is supported by ggtree >= 2.4.0

The following is the development version (github).

> packageVersion("ggtree")
[1] ‘3.3.1’

xiangpin avatar Dec 30 '21 02:12 xiangpin

Thanks for the reminder!

Now it is solved!

Tsingsjeen avatar Dec 30 '21 12:12 Tsingsjeen