I built a phylogenetic tree for a family of proteins that can be divided into different groups, classifying each by receptor type or response type. Nodes in the tree are marked as receptor type.
In the phylogenetic tree, I see that proteins belonging to the same groups or receptor type are grouped together in the same branches. Therefore, I would like to collapse these branches that have common tags, grouping them according to a specific list of keywords.
The command will look something like this:
./collapse_tree_by_label -f phylogenetic_tree.newick -l list_of_labels_to_collapse.txt -o collapsed_tree.eps (or pdf)
My list_of_labels_to_collapse.txt will look like this: In C D
My new tree will look like this: (A_1: 0.05, A_2: 0.03, A_3: 0.2, A_4: 0.1): 0.9, (((B_1: 0.05, B_2: 0.02, B_3: 0.04): 0.6, (C_1: 0.6, C_2: 0.08): 0.7): 0.5, (D_1: 0.3, D_2: 0.4, D_3: 0.5, D_4 : 0.7, D_5: 0.4): 1.2)
The output image without smoothing looks like this: http://i.stack.imgur.com/pHkoQ.png
Collapsing the output image should be like this (collapsed_tree.eps): http://i.stack.imgur.com/TLXd0.png
The width of the triangles should represent the length of the branch, and the top of the triangles should represent the number of nodes in the branches.
I played with the βapeβ package in R. I managed to build a phylogenetic tree, but I still canβt figure out how to collapse the branches by keywords in the labels:
require("ape")
This will load the tree:
cat("((A_1:0.05,A_2:0.03,A_3:0.2,A_4:0.1):0.9,(((B_1:0.05,B_2:0.02,B_3:0.04):0.6,(C_1:0.6,C_2:0.08):0.7):0.5,(D_1:0.3,D_2:0.4,D_3:0.5,D_4:0.7,D_5:0.4):1.2):0.5);", file = "ex.tre", sep = "\n") tree.test <- read.tree("ex.tre")
There should be a code to reset
This will build a tree:
plot(tree.test)