Skip to content

compute covariance matrix and PCA #275

Closed

Description

@petrelharp

To compute a covariance matrix, or do PCA, we currently have to export the genotype matrix. It would be nice to do this using the statistics framework, and totally do-able. It is also possible to find PCs without computing the covariance matrix first. This would be a nice compact but very useful contribution for someone to take on.

Activity

  1. added
    enhancement
    on Jul 30, 2019
  2. daniel-trejobanos commented on Nov 1, 2019

    @daniel-trejobanos

    I am curious about this, specially how to compute the PCA without the covariance matrix? do you have a paper explaining this?

  3. petrelharp commented on Nov 2, 2019

    @petrelharp
    ContributorAuthor

    I have not worked out the details, but the basic idea is that the PCs are the eigenvectors of the genetic covariance matrix, and modern iterative methods (like Krylov methods) exist to find the eigenvectors of a matrix A without ever computing A explicitly, but rather finding the result of multiplying A by some random vectors. This paper: https://www.ncbi.nlm.nih.gov/pubmed/26924531 does something like this. In our situation, A = G^T G, where G is the genotype matrix (possibly normalized), and so we can use our general statistics to quickly compute u^T A v for vectors u and v.

    That's the general idea. I have not worked out the details, so it's possible there's something very tricky in there, but I'm happy to help work it through.

  4. hyanwong commented on Jul 5, 2023

    @hyanwong
    Member

    Also see performance issues in #1743

  5. hanbin973 commented on Mar 17, 2025

    @hanbin973
    Contributor

    I think we can close this issue with 0f7fa20 ?

  6. petrelharp commented on Mar 19, 2025

    @petrelharp
    ContributorAuthor

    🎉 Closed in #3008 and other places!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementstatistics

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions