abidlabs / contrastive

Contrastive PCA
MIT License
199 stars 47 forks source link

Why do you adjust the sign here? #10

Closed dbeach24 closed 5 years ago

dbeach24 commented 5 years ago

In the code below, you appear to be adjusting the sign of the first two dimensions of the data projected into cPCA space. Why only the first two? Should this depend on the number of components specified by the user?

https://github.com/abidlabs/contrastive/blob/03d138451f7caefa6903267b37e7c8442aca084a/contrastive/__init__.py#L298

abidlabs commented 5 years ago

Hi @dbeach24, thanks for the question. We adjust the sign to encourage the eigenvectors to be "oriented" the same way as we adjust the values of alpha. We find this allows for more consistent visualizations of PCA plots as we vary the value of alpha (and since eigenvectors can be scaled by constants, there's no problem with doing so). But you are right, the same procedure should be repeated for all of the eigenvectors, not just the 2 components, thanks for catching that!