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


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


Blighe, Kevin, and Aaron Lun. 2020. PCAtools: Everything Principal Components Analysis.

Dowle, Matt, and Arun Srinivasan. 2020. Data.table: Extension of ‘Data.frame‘.

Kolde, Raivo. 2019. Pheatmap: Pretty Heatmaps.

Wickham, Hadley. 2019. Tidyverse: Easily Install and Load the 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.