Re: [R] Principal component analysis PCA

From: Thomas Lumley <tlumley_at_u.washington.edu>
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

   cov(t(code))
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

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley_at_u.washington.edu	University of Washington, Seattle

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive