system(glue::glue("/bin/plink/plink --bfile ./hapmap3_ch22 --pca --out ./pca"))
= read.table(glue::glue("./pca.eigenvec"),header=F, as.is=T)
pcplink names(pcplink) = c("FID","IID",paste0("PC", c(1:(ncol(pcplink)-2))))
= popinfo %>% inner_join(pcplink, by=c("FID"="FID", "IID"="IID"))
pcplink %>%
pcplink filter(population =="CEU"|population=="YRI"|population=="ASW"|population=="CHB") %>%
ggplot(aes(PC1,PC2,col=population)) +
geom_point(size=3,alpha=.7) +
theme_bw(base_size = 15)
Part-1: html
rendered from .Rmd
files
This example was created from a .Rmd
file using Quarto.
Population structure
Calculate principal components using chromosome 22. Plot PC1 vs PC2 using different color for each population. Keep only CEU, YRI, ASW, and CHB before plotting.