Dear Liam and Leandro,

Thanks for your replies but think that i have not explained correctly. For
example, i have a phylogeny with all branch lengths egual to 1:

library(ape)

tree.1<-read.tree(text="(((A:1.0,B:1.0):1.0,(C:1.0,(D:1.0,E:1.0):1.0):1.0):1.0,F:1.0);")

plot(tree.1)

See that the branch length of taxon "F" is igual to 1 but it is
proportionally equivalent to four smaller branchs. Therefore, i would like
to rescale all branch lengths of the phylogeny like this:

tree.2<-read.tree(text="(((A:1.0,B:1.0):2.0,(C:2.0,(D:1.0,E:1.0):1.0):1.0):1.0,F:4.0);")

plot(tree.2)

Today i make this transformation in the "Fig Tree" software using the
options: >Trees>Transform branches>cladogram. However, i still could not
get make this in the R.

All the best,

Fernando L. Sobral

2012/8/28 Liam J. Revell <liam.rev...@umb.edu>

> 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/<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<https://stat.ethz.ch/mailman/listinfo/r-sig-phylo>
>>
>>

        [[alternative HTML version deleted]]

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

Reply via email to