Re: [R] Principal component analysis PCA

From: Thomas Lumley <>
Date: Thu, 14 Feb 2008 13:28:16 -0800 (PST)

On Thu, 14 Feb 2008, SNN wrote:

> Thanks for the advice.
> I tried to find the cov of my matrix using R and it ran out of memory.

How did you do this? The covariance matrix is only 115x115, so it shouldn't run out of memory

should work

If that doesn't work then

   tcrossprod(code)/300000 - tcrossprod(rowMeans(code)) might.

> I am
> not sure how to do double loop to create the covariace matrix? Also is
> doing prcomp( covariace matrix) the same as finding
> prcomp( original data ,matrix of snps)?

That's the point of the paper behind the EIGENSTRAT software, which is worth reading. The eigenvalues are the same and the eigenvectors are related. One way around gives the left singular vectors of the data matrix, the other gives the right singular vectors.


Thomas Lumley			Assoc. Professor, Biostatistics	University of Washington, Seattle

______________________________________________ mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu 14 Feb 2008 - 21:32:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 14 Feb 2008 - 22:30:13 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive