Thursday, May 20, 2010

Tutorial: Principal Components Analysis (PCA) in R

Found this tutorial by Emily Mankin on how to do principal components analysis (PCA) using R. Has a nice example with R code and several good references. The example starts by doing the PCA manually, then uses R's built in prcomp() function to do the same PCA.

Principle Components Analysis: A How-To Manual for R

11 comments:

  1. Hi there,
    great posting but unfortunately I'm having some difficulties executing the following code from Box 3:

    X=Xoriginal-matrix(rep(rm, dim(X)[2]), nrow=dim(X)[1])

    Shouldn't the X on the RHS of the formula be Xoriginal?
    Thanks,
    Ruben

    ReplyDelete
  2. I've personally had memory allocation issues when doing PCA with genetic data (e.g., implementing my own Eigenstrat-type method). Has anyone tried this version with, say, 100k markers & 1000 samples or something comparable?

    ReplyDelete
  3. is the manual shown above available..?I have been trying for a couple of days to d/l it
    Thanks
    Sajan

    ReplyDelete
  4. Hmm, I'm having trouble accessing it too. I'll email the folks at Colorado and see if they can get this back online.

    ReplyDelete
  5. Can't read the article!

    ReplyDelete
  6. You can find it here: http://www.scribd.com/doc/39718072/PCA-How-To-1

    ReplyDelete
  7. Great article ! Thank you

    ReplyDelete
  8. Very approximative maths, plenty of typos (e.g., if X is an mxn matrix, XX^t is certainly not a nxn matrix.
    NOT recommended.

    ReplyDelete
  9. I have problem reading/downloading the article

    ReplyDelete
  10. I've got this link for the article, please check if it's the one?

    http://psych.colorado.edu/wiki/lib/exe/fetch.php?media=labs:learnr:emily_-_principal_components_analysis_in_r:pca_how_to.pdf

    ReplyDelete

Note: Only a member of this blog may post a comment.

Creative Commons License
Getting Genetics Done by Stephen Turner is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.