# open an example dataset (HapMap)
genofile <- snpgdsOpen(snpgdsExampleFileName())
rv <- snpgdsGRM(genofile, method="Visscher")
eig <- eigen(rv$grm) # Eigendecomposition
pop <- factor(read.gdsn(index.gdsn(genofile, "sample.annot/pop.group")))
plot(eig$vectors[,1], eig$vectors[,2], col=pop)
legend("topleft", legend=levels(pop), pch=19, col=1:4)
# close the file
snpgdsClose(genofile)
Run the code above in your browser using DataLab