Thursday, December 1, 2011

Percent variance from phyl.pca()

A user just emailed me to find out how to get the "percent variance explained" by each eigenvector from phytools' phylogenetic PCA (phyl.pca function. This is easy, just do the following:

> require(phytools)
> res<-phyl.pca(tree,X)
> diag(res$Eval)/sum(res$Eval)*100
     PC1      PC2      PC3      PC4      PC5 
26.83767 23.78144 20.18687 15.85040 13.34361


No comments:

Post a Comment

Note: due to the very large amount of spam, all comments are now automatically submitted for moderation.