Simple question. How would we project a new vector onto PCA space using snpgdsPCA( ), given that there is no option to return the variant weights in snpgdsPCA( )? Is there anyway to infer the weights in R? I see the option need.genmat returns the covariance matrix – maybe this can be used to infer variant weights?
Note, other packages have an option to return weights like plink and prcomp, so this is not an uncommon request.
You can use the functions snpgdsSNPLoading and snpgdsPCASampLoading to project new samples onto existing PCA eigenvectors. From the man page for snpgdsPCASampLoading:
# first PCA
pca <- snpgdsPCA(genofile, eigen.cnt=8)
snp_load <- snpgdsPCASNPLoading(pca, genofile)
# calculate sample eigenvectors from SNP loadings
samp_load <- snpgdsPCASampLoading(snp_load, genofile, sample.id=sample.id)