You could do this with the R library APE:
tr <- rtree(15, br=NULL)
tr$node.label <- rep("#1", Nnode(tr))
write.tree(tr)
## [1] "((((t14,t7)#1,t6)#1,(t2,t12)#1)#1,(((((t1,t9)#1,t5)#1,t4)#1,t15)#1,((t10,t13)#1,(t8,(t11,t3)#1)#1)#1)#1)#1;"
But I'm not sure you need to? Isn't the node-labeling format only used if you want o compare ka/ks among different branch sets? I;m not sure why you'd set all branches to one set
EDIT
OK, so a didn't quite get the question. If you want to label every node that is ancestral to a given tip you you make use of the Ancestors
function in the library phangorn. An example
library(phangorn)
library(ape)
label_lineage <- function(tr, taxon_name){
lineage <- Ancestors(tr, which(tr$tip.label == taxon_name)) - Ntip(tr)
tr$node.label <- ifelse(1:Nnode(tr) %in% lineage, "#1", "")
return(tr)
}
set.seed(123)
tr <- rtree(15, br=NULL)
write.tree(label_lineage(tr, "t14"))
##[1] "((((t7,t14)#1,(t6,t9))#1,t15)#1,(((t2,(((t12,t10),t1),((t8,t5),t4))),t3),(t13,t11)))#1;"
#check it makes sense
plot(label_lineage(tr, "t14"), show.node.label=TRUE)
#a more interesting one
plot(label_lineage(tr, "t12"), show.node.label=TRUE)
(I'm still not clear that there is a biological reason to want to do this, but at least you can run it now!)
Thanks, worked perfectly.
I want to test the selective pressure in all lineages but trying to reduce the effect of the low divergence problem. In my set of genes i detected ~10-20 genes under selection in spefific terminal branches, but in humam only 2, i supose is the low divergence time with the chimp, since only the branch that point is tested, and will also turn impossible the presence of branches with dS=0. The free-ratio should be avoid since has too much parameters to consider. So i decided to try like this.
Do you think is an incorrect approach? I am learning...
Thanks,
Jp