YuLab-SMU / ggtree

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

tree file and metadata file not same length (aes) #250

Open TseWue opened 5 years ago

TseWue commented 5 years ago

Dear Guangchuang

I am a huge fan of ggtree, thanks for developing this amazing tool! I just tried to annotate my tree with some additional metadata according to https://aschuerch.github.io/posts/2017-04-24-blog-post-1. In principle it is working, but R throws an error at me for the length of the aestetics (Error: Aesthetics must be either length 1 or the same as the data (10608): colour)). I don't understand why this is happening. I have a newick file and a metadata file and the metadata file only contains 2 columns:

tail(meta) name category 9561 SV61 non-database 9562 CP010063.1 Enterococcus cecorum database 9563 CP010062.1 Enterococcus cecorum database 9564 CP010059.1 Enterococcus cecorum database 9565 CP010061.1 Enterococcus cecorum database 9566 SV661 non-database

Now since I derived the metadata from the alignemnt file that was used to create the newick tree, the number of sequences must be the same. Yet, the newick file data seems to be longer as the meta-data. Why is that and is there a work around? How else can I annotate the two different categories? I need to have each individual leaf annotated.

Thank you so much for your help! Best wishes, Tse

P.S.: Also, depending on what parameters I change I get the following error message: Error: Must request at least one colour from a hue palette. But If the length was the same I could solve this easily. And if you have the chance to reply today I would appreciate that very much - I'm a bit in a hurry... :-)

GuangchuangYu commented 5 years ago

see examples in supplemental file of https://academic.oup.com/mbe/article/35/12/3041/5142656.