Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting Problem of Evolutionary Leaf Node Labels//咨询进化树叶节点的排序问题 #617

Open
shenzhenzth opened this issue May 29, 2024 · 3 comments

Comments

@shenzhenzth
Copy link

Dear author
I have a simple question to consult, but it does confuse me.
When I use ggtree, the order of tree $tip. label is always the order in the imported evolutionary tree,
I discovered through reading page 128 of "R Practical" that ggtree provides a few functions for adjusting the structure called flip,
If you want to adjust the order of the evolutionary tree in the specified order, can you use ggtree?
In addition, I have found that the visualization results of the tree are not completely consistent with the order of the tree $tip. label. I would like to boldly ask what is the logic of this arrangement order?
If you could not hesitate to give me advice, I would be extremely grateful.
Wishing you a pleasant life and work
A new fan of Uncle Y

亲爱的作者
我有一个简单的问题想要咨询,但是这个确实使我感到困惑。
当我使用ggtree的时候,tree$tip.label的顺序永远是导入的进化树中的顺序,
我通过阅读《R实战》128页发现了ggtree提供了少部分调整结构的函数flip,
如果想要按照指定的顺序去调整进化树的顺序,用ggtree是否能做到?
另外我发现tree在可视化的结果中,并不完全与tree$tip.label的顺序一致,想斗胆请教一下这个排列顺序的逻辑是什么?
如能不吝赐教、当真万分感谢。

祝您生活工作愉快
Y叔的粉丝

@brj1
Copy link
Contributor

brj1 commented May 29, 2024

With ggdensitree you can choose the tip order. ggdensitree is for plotting multiple trees though, so it takes a list of trees.

library(ggtree)

# example tree
set.seed(0)
tree <- rtree(5)

# ggtree
ggtree(tree) + geom_tiplab()

# ggdensitree
ggdensitree(list(tree), layout = 'rectangular') + geom_tiplab()

# tip.order can be used to reorder tips
ggdensitree(list(tree), layout = 'rectangular', tip.order = paste0("t", 1:5)) + geom_tiplab()

# you can also put a more reasonable order
ggdensitree(list(tree), layout = 'rectangular', tip.order = c("t2", "t5", "t1", "t3", "t4")) + geom_tiplab()

By default ggtree puts the tip labels in the order which ladderizes the tree (arranges the splits so that smaller clades go below larger clades). You can set ladderize = FALSE in ggtree's options to have it arrange tips in the order order they appear in the tree's newick file.

@shenzhenzth
Copy link
Author

Thank you very much
I will definitely read and use the documentation carefully in the future.

Can I ask one more question?
If I want to export tree by particular "tip.order", can the demand be realized?
"write.beast" function and others seemly can not do this?

Best wishes.

1 similar comment
@shenzhenzth
Copy link
Author

Thank you very much
I will definitely read and use the documentation carefully in the future.

Can I ask one more question?
If I want to export tree by particular "tip.order", can the demand be realized?
"write.beast" function and others seemly can not do this?

Best wishes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants