Root-To-Tip Tree Labeling
2
0
Entering edit mode
11.8 years ago
jprmachado ▴ 80

Hi,

I am to label a tree with #1 in all the nodes, from root to the leaf.

Example:

(((Sp1  #1 , Sp2)  #1,  Sp3) #1 ,(Sp4,Sp5));   for Sp1
(((Sp1, Sp2  #1 )  #1 , Sp 3) #1 ,(Sp4,Sp5));  for Sp2
(((Sp1, Sp2), Sp3 #1 ) #1 ,(Sp4,Sp5));         for Sp3
(((Sp1, Sp2), Sp3),(Sp4#1,Sp5) #1 );           for Sp4
(((Sp1, Sp2), Sp3),(Sp4,Sp5 #1)#1);            for Sp5

In my real data i will have from 20 to 39 species, and this for many genes, so is impractical to do it manually, does anyone knows any software or script to do it?

Thanks in advance,

João Paulo

paml phylogenetics • 2.8k views
ADD COMMENT
3
Entering edit mode
11.8 years ago
David W 4.9k

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!)

ADD COMMENT
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1069 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6