[R-sig-phylo] apTreeshape and odd Colless scores

2012-09-03 Thread Simon Greenhill
Hi all,

I've noticed that apTreeshape's _colless_ and _colless.test_ functions can give 
normalised/standardised Ic values outside the expected range of 0-1. 

For example,

getcolless - function(tips) { 
# randomly generate a tree, and get the normalized Colless score.
colless(as.treeshape(rtree(tips)), norm=yule) 
}
values - replicate(1000, getcolless(500))

summary(values)

Min.  1st Qu.   Median Mean  3rd Qu. Max. 
-1.81300 -0.62920 -0.12870 -0.05046  0.42530  4.40900 


... so, there's a lot of trees that are outside 0-1. If, however, I manually 
calculate Ic using some code I found elsewhere on the internet, then I get the 
following:

getcolless2 - function(tips) {
b = balance(rtree(tips))
Ic = (sum(abs(b[,1]-b[,2])))/(((tips-1)/2)*(tips-2))
}

values - replicate(1000, getcolless2(500))

summary(values)

   Min. 1st Qu.  MedianMean 3rd Qu.Max. 
0.01278 0.01820 0.02012 0.02055 0.02249 0.03451 

... which is very different. The second method gives me values very similar to 
what Mesquite gives me. Is this a bug in apTreeshape? Or am I interpreting 
apTreeshape's norm parameter incorrectly?

Cheers,
Simon

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


Re: [R-sig-phylo] apTreeshape and odd Colless scores

2012-09-03 Thread Blum michael

Dear Simon,

Normalization does not necessarily returns values between 0 and 1 but 
returns the values of the summary statistics divided by the standard 
deviation of the summary statistics that is expected under the Yule 
model. If you want to use that renormalization to compare tree shapes 
for different tree sizes, I would rather suggest to use the 
beta-splitting statistic also implemented in the R package.


Hope this helps
Michael Blum

Hi all,

I've noticed that apTreeshape's _colless_ and _colless.test_ functions can give 
normalised/standardised Ic values outside the expected range of 0-1.

For example,

getcolless - function(tips) {
# randomly generate a tree, and get the normalized Colless score.
colless(as.treeshape(rtree(tips)), norm=yule)
}
values - replicate(1000, getcolless(500))

summary(values)

 Min.  1st Qu.   Median Mean  3rd Qu. Max.
-1.81300 -0.62920 -0.12870 -0.05046  0.42530  4.40900


... so, there's a lot of trees that are outside 0-1. If, however, I manually 
calculate Ic using some code I found elsewhere on the internet, then I get the 
following:

getcolless2 - function(tips) {
 b = balance(rtree(tips))
 Ic = (sum(abs(b[,1]-b[,2])))/(((tips-1)/2)*(tips-2))
}

values - replicate(1000, getcolless2(500))

summary(values)

Min. 1st Qu.  MedianMean 3rd Qu.Max.
0.01278 0.01820 0.02012 0.02055 0.02249 0.03451

... which is very different. The second method gives me values very similar to what 
Mesquite gives me. Is this a bug in apTreeshape? Or am I interpreting apTreeshape's 
norm parameter incorrectly?

Cheers,
Simon

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



--
--
Michael BLUM
CNRS Research Associate
Tel: +33 (0)4 56 52 00 65
Fax: +33 (0)4 56 52 00 55
michael.b...@imag.fr
http://membres-timc.imag.fr/Michael.Blum/

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


Re: [R-sig-phylo] tips to root brach length

2012-09-03 Thread Simon Blomberg

try

diag(vcv.phylo(your.tree))

Cheers,

Simon.

On 03/09/12 19:17, boyang zhe wrote:

Hi, everyone

I am new to ape and R programming. I have an unrooted tree. I use
root() function to reroot the tree by one outgroup. and then I try to
extract root to tip distance. the tree$edge.length only store the
brach length between each tip and corresponding internal node. So how
I extract the distance between root and the tips?

Thanks first!

Boyang

___
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


Re: [R-sig-phylo] tips to root brach length

2012-09-03 Thread Liam J. Revell
Hi. Try:

diag(vcv.phylo(tree))

nodeHeights in phytools will also give you a matrix with all the heights of 
internal and terminal nodes in the same order as tree$edge.

- Liam 

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

-Original Message-
From: boyang zhe
Sent: Monday, September 03, 2012 5:17 AM
To: r-sig-phylo@r-project.org
Subject: [R-sig-phylo] tips to root brach length

Hi, everyone

I am new to ape and R programming. I have an unrooted tree. I use
root() function to reroot the tree by one outgroup. and then I try to
extract root to tip distance. the tree$edge.length only store the
brach length between each tip and corresponding internal node. So how
I extract the distance between root and the tips?

Thanks first!

Boyang

___
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