Closed wanxn518 closed 3 weeks ago
Hi XiaoNan,
Regarding your question, there is an example that demonstrates how to rename internal node labels: Lines 1773-1807 in the GitHub repository at https://github.com/TongZhou2017/itol.toolkit/blob/d2eac45180be6336b5acb949e21e4ba0738eb4a8/R/user.R#L1773.
In phylogenetic tree files, internal node labels are not required elements. Therefore, they sometimes need to be named manually.
I hope these tips help provide some guidance. Please let me know if you have any other questions as you work with renaming internal nodes. I'm happy to offer additional examples or clarification.
Best regards, Tong
Hi Dr. Zhou
Thank you very much for your reply!
I want to change the name of the internal node of the tree so that the specific branch can be folded. Just like the tree_of_itol_templates.tree you provided in dataset1, the name of this sample tree at some specific nodes is the group name, so the branches belonging to this group can be folded according to these known tags;
Sample tree in dataset1, some nodes have added grouping labels: So we can collapse the branches under these nodes according to the group name:
library(itol.toolkit)
tree <- system.file("extdata","tree_of_itol_templates.tree",package = "itol.toolkit")
data("template_groups")
group_names <- unique(c("tree_sturcture", "theme_style", "text", "basic_plot"))
unit_2 <- create_unit(data = group_names, key = "E002_collapse_2", type = "COLLAPSE", tree = tree)
write_unit(unit_2,paste0(getwd(),"/E002_collapse_2.txt"))
Although I can modify node labels manually, my whole tree has thousands of branches, and it seems inefficient to add node labels manually.
Is the node label in the sample tree in dataset1 modified by [itol.toolkit/R/user.R](https://github.com/TongZhou2017/itol.toolkit/blob/d2eac45180be6336b5acb949e21e4ba0738eb4a8/R/user.R#L1773)
?
I'm a novice at itol.toolkit, and I'm sorry to disturb you.
Best, XiaoNan
I see, for the tree in dataset1, you can use the L1773 function which automatically adds internal node labels when clustering by group model. This is an important point - typically internal node labels are automatically generated by the tree building tools like MEGA, FASTTREE, etc.
If your tree does not have internal node labels originally, you can use the makeNodeLabel() function from the ape package in R to add dummy internal node labels. This will allow you to then specify the internal nodes for collapsing branches.
The key points are:
Let me know if this helps explain the issue with missing internal node labels. I'm happy to clarify further if needed!
Hi Dr. Zhou
There is an example of renaming a leaf node in https://tongzhou2017.github.io/itol.toolkit/articles/LABELS.html, but can I use the "LABELS" module in itol.toolkit to rename the internal nodes of a tree? Is there a tutorial for renaming the internal nodes of a tree? I look forward to your reply and appreciate it very much.
Best, XiaoNan