Rosemeis / pcangsd

Framework for analyzing low depth NGS data in heterogeneous populations using PCA.
GNU General Public License v3.0
46 stars 11 forks source link

How to get PCs from the covariance matrix #28

Closed clairemerot closed 4 years ago

clairemerot commented 4 years ago

Hello, I am using pcangsd and getting a covariance matrix. Until now I was simply applying a PCA on the covariance matrix using the "prcomp" unscale fonction in R and plotting/analysing the PC outputs.

Yet, the prcomp function is rather supposed to be applied on raw data and include in itself the passage through the covariance matrix. So I am unsure whether it is correct to apply a PCA on the covariance matrix. First trial seems to show that a pca on data et different than a pca on the covariance matrix of the data.

So I'm curious to know how pcangsd users deal with the covariance matrix and how in the paper you went from the covariance matrix to the PC representation.

Thanks a lot for your help

Claire

clairemerot commented 4 years ago

Sorry, I found the solution. Migth be useful for somebody else. One can use the function eigen in R which makes the decomposition of the covariance matrix into eigenvectors (=PCs) and eigenvalues. My apologies!