Hi Fernando.

I'm not entirely sure what you're going for, but let me try to be of some help.

The tree is stored in memory as what is called a "list" - basically, a set of objects that can be of different types. The branch lengths of the tree are stored in the list element "edge.length". So, for a "phylo" object with the variable name tree, you can access the branch lengths of the tree using tree$edge.length. (If your tree does not have branch lengths, this will be NULL.)

Consequently, you can assign any arbitrary values to the branch lengths of the tree by assigning values to tree$edge.length. For instance, to set all branch lengths to 1.0, you would just do:

tree$edge.length<-rep(1,nrow(tree$edge))

The order of tree$edge.length corresponds to the row order of tree$edge, so if you want to see which branches in tree$edge.length correspond to which branches on the tree, you can do something like the following (here, I use a simple random tree for illustration):

set.seed(1)
tree<-rtree(10); tree$edge.length<-rep(1,nrow(tree$edge))
X<-tree$edge
X[X[,2]%in%1:length(tree$tip),2]<-
   tree$tip[X[X[,2]%in%1:length(tree$tip),2]]
names(tree$edge.length)<-paste(X[,1],X[,2],sep=",")
plot(tree); nodelabels()
tree$edge.length

Now if, for instance, I want to make the branch length leading from node 13 to tip taxon "t6" to (for instance) 3.0, I could just do:

tree$edge.length["13,t6"]<-3
plot(tree); nodelabels()

Of course, if we have some simple criterion on which we want to change our branch lengths, we can do that to. For instance, if we wanted to set all branch lengths with length <1 to 1.0 and all branch lengths with length >1 to 2.0, we could do it as follows:

tree$edge.length<-runif(n=nrow(tree$edge),min=0,max=2)
tree$edge.length
tree$edge.length[tree$edge.length<1]<-1
tree$edge.length[tree$edge.length>1]<-2
tree$edge.length
plot(tree)

I hope this is of some help.

All the best, Liam

Liam J. Revell, Assistant Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: liam.rev...@umb.edu
blog: http://phytools.blogspot.com

On 8/28/2012 4:15 PM, Fernando Sobral wrote:
Hi,

I am trying to alter the branch lengths of a phylogeny so that the smaller
branch has size igual 1 and the larger branch is the proportional sum of
the smaller branchs. For example, if the larger branch is equivalent to ten
smaller branchs, it should have size igual to 10. I already tryed use some
functions like compute.brlen(), compute.brtime() and rescaleTree(), but did
not work.

Any help would be greatly appreciated.

Thanks,

Fernando L. Sobral

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo

Reply via email to