YuLab-SMU / ggtree

:christmas_tree:Visualization and annotation of phylogenetic trees
https://yulab-smu.top/contribution-tree-data/
838 stars 173 forks source link

error in facet_plot():invalid tbl_tree object. Missing column: parent,node. #575

Open Avamost1 opened 1 year ago

Avamost1 commented 1 year ago

Hi I encountered the following error when using facet_plot():

map=read.table("map.txt", header=T, sep="\t", comment.char="")
tree_all <- read.tree(file = 'gtdbtk.unrooted_all.tree')
comp <- map[,c(1,3)]
p = ggtree(tree_all,ladderize=FALSE,layout="circular",size=0.8,branch.length="none", aes(col=classification))  %<+% map +
  geom_tippoint(size=3)+
  geom_tiplab(align=TRUE,aes(label=NA))
  theme(legend.title=element_text(face="bold"), legend.position="right", legend.box="horizontal", legend.text=element_text(size=rel(0.8)))
plot <- facet_plot(p,panel = 'comp', data = comp , geom = geom_barh, aes(x=completness), fill="#db616a", color="#db616a", stat='identity')
ℹ invalid tbl_tree object. Missing column: parent,node.
ℹ invalid tbl_tree object. Missing column: parent,node.
>head(map)
            genome      classification completeness contamination
1 JS_SC_co_bin.177 p__Actinobacteriota        97.58          1.61
2 JS_SC_co_bin.149 p__Actinobacteriota        98.47          0.00
3 JS_SC_co_bin.292 p__Actinobacteriota        72.50          3.79
4 JS_SC_co_bin.151 p__Actinobacteriota        92.06          3.23
5 JS_SC_co_bin.184   p__Armatimonadota        94.44          0.93
6 JS_SC_co_bin.140   p__Armatimonadota        60.63          2.37
> head(comp)
            genome completeness
1 JS_SC_co_bin.177        97.58
2 JS_SC_co_bin.149        98.47
3 JS_SC_co_bin.292        72.50
4 JS_SC_co_bin.151        92.06
5 JS_SC_co_bin.184        94.44
6 JS_SC_co_bin.140        60.63

How can i fix it?

shajdksadoiwqdhwqdkj commented 1 year ago

I came across this problem too. However, this problem won't stop us from plotting the plot.

ca57e9889c78a1821740a88f63a7946