Chapter 7 PCA analysis

7.1 PCA and Kinship visualization

In this section we will examine population structure using the PCAtools R package (Blighe and Lun 2020) and visualize the Kinship matrix calculated from the previous section using the pheatmap R package (Kolde 2019).

Other packages used in this section include rMVP (Yin et al. 2020), data.table (Dowle and Srinivasan 2020), tidyverse (Wickham 2019) and pheatmap (Kolde 2019)

Load required pacakges

Set working directory to where rMVP formatted files are in workshop materials

Load SNP matrix, phenotypes and Kinship matrix

Run PCA

Put results of the first 3 PCs into a dataframe

Make a scatterplot of the first 3 PCs

Correlation of simulated phenotypes with forst 3 PCs

Make a heatmap of the Kinship matrix

References

Blighe, Kevin, and Aaron Lun. 2020. PCAtools: Everything Principal Components Analysis. https://github.com/kevinblighe/PCAtools.

Dowle, Matt, and Arun Srinivasan. 2020. Data.table: Extension of ‘Data.frame‘. https://CRAN.R-project.org/package=data.table.

Kolde, Raivo. 2019. Pheatmap: Pretty Heatmaps. https://CRAN.R-project.org/package=pheatmap.

Wickham, Hadley. 2019. Tidyverse: Easily Install and Load the Tidyverse. https://CRAN.R-project.org/package=tidyverse.

Yin, Lilin, Haohao Zhang, Zhenshuang Tang, Jingya Xu, Dong Yin, Zhiwu Zhang, Xiaohui Yuan, et al. 2020. RMVP: Memory-Efficient, Visualize-Enhanced, Parallel-Accelerated Gwas Tool. https://github.com/xiaolei-lab/rMVP.