I have a phylogenetic tree made with a Newick format
((a:1,b:1):2, (c:1, d:1):3):1;
The output will be
I have drawn this with http://etetoolkit.org/treeview/ , but output with R will be same.
What I want to do is apply colors to a certain branch.
That would be
Since the Newick input doesn't include any information other than the branch (c,d) has length 3, is there any way I can include multiple color information on the branch?
I usually use ggtree for making trees, but other suggestions can be helpful.
One solution would be to split the internal branches by adding extra non-bifurcating nodes.
library(ape)
## Creating the same tree with split branches
my_with_split_branch_tree <- read.tree(text = "((a:1,b:1):2, ((((c:1, d:1):1):1):1):1):1;")
## Set the edge colors and width
edge_colors <- rep("black", Nedge(my_with_split_branch_tree))
edge_width <- rep(1, Nedge(my_with_split_branch_tree))
## Color and width the edges of interest
edge_colors[c(5,6,7)] <- c("yellow", "orange", "red")
edge_width[c(5,6,7)] <- 3
## Plotting the tree with the colours
plot(my_with_split_branch_tree,
edge.color = edge_colors,
edge.width = edge_width)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.