7 Computing a GRM

We can use the SNPRelate package to compute a Genetic Relationship matrix (GRM). This method combines relatedness due to more distant ancestry and recent kinship into a single matrix.

SNPRelate offers several algorithms for computing a GRM, including the commonly-used GCTA Yang et al 2011. The most recent algorithm added to the package is “IndivBeta” Weir and Goudet 2017.

library(SeqArray)
repo_path <- "https://github.com/UW-GAC/SISG_2020/raw/master"
if (!dir.exists("data")) dir.create("data")
gdsfile <- "data/1KG_phase3_subset_chr1.gds"
if (!file.exists(gdsfile)) download.file(file.path(repo_path, gdsfile), gdsfile)
gdsfmt::showfile.gds(closeall=TRUE) # make sure file is not already open
gds <- seqOpen(gdsfile)

library(SNPRelate)
grm <- snpgdsGRM(gds, method="GCTA")
## Genetic Relationship Matrix (GRM, GCTA):
## Calculating allele counts/frequencies ...
## 
[..................................................]  0%, ETC: ---    
[==================================================] 100%, completed, 1s
## Excluding 13 SNVs (monomorphic: TRUE, MAF: NaN, missing rate: NaN)
## Working space: 1,126 samples, 1,107 SNVs
##     using 1 (CPU) core
## CPU capabilities: Double-Precision SSE2
## Mon Jul 27 15:04:46 2020    (internal increment: 664)
## 
[..................................................]  0%, ETC: ---        
[==================================================] 100%, completed, 0s
## Mon Jul 27 15:04:46 2020    Done.
names(grm)
## [1] "sample.id" "snp.id"    "method"    "grm"
dim(grm$grm)
## [1] 1126 1126
seqClose(gds)