liamrevell / phytools

GNU General Public License v3.0
198 stars 56 forks source link

Dumb question: Why are the PCA scores different from the positions of the points in a plot of the PCA? #142

Closed aleungplants closed 8 months ago

aleungplants commented 11 months ago
library(phytools)
library(ggfortify)

data(anoletree)
data(anole.data)
pca<-phyl.pca(anoletree,anole.data,mode="cov")
pca<-as.princomp(pca)
pca$scores
autoplot(pca)

Say, if I run this code, the Comp.1 values in the figure only go up to 0.5, but the values in pca$scores go up to 1.5... what am I missing here?

liamrevell commented 8 months ago

I think you should probably investigate what autoplot does. Perhaps it first normalizes the scores in some way? If you run, instead, plot(pca$scores[,1:2]) you should see values that make sense.