Learn R Programming

SNPRelate (version 1.6.4)

snpgdsGRM: Genetic Relationship Matrix (GRM) for SNP genotype data

Description

Calculate Genetic Relationship Matrix (GRM) using SNP genotype data.

Usage

snpgdsGRM(gdsobj, sample.id=NULL, snp.id=NULL, autosome.only=TRUE, remove.monosnp=TRUE, maf=NaN, missing.rate=NaN, method=c("Visscher", "Eigenstrat", "EIGMIX", "W&Z15"), num.thread=1L, with.id=TRUE, verbose=TRUE)

Arguments

gdsobj
an object of class SNPGDSFileClass, a SNP GDS file
sample.id
a vector of sample id specifying selected samples; if NULL, all samples are used
snp.id
a vector of snp id specifying selected SNPs; if NULL, all SNPs are used
autosome.only
if TRUE, use autosomal SNPs only; if it is a numeric or character value, keep SNPs according to the specified chromosome
remove.monosnp
if TRUE, remove monomorphic SNPs
maf
to use the SNPs with ">= maf" only; if NaN, no MAF threshold
missing.rate
to use the SNPs with "
method
"Visscher" -- genetic relationship matrix defined in CGTA; "Eigenstrat" -- genetic covariance matrix in EIGENSTRAT; "EIGMIX" -- coancestry matrix defined in Zheng & Weir (2015), "W&Z15" -- individual beta estimator
num.thread
the number of (CPU) cores used; if NA, detect the number of cores automatically
with.id
if TRUE, the returned value with sample.id and sample.id
verbose
if TRUE, show information

Value

Return a list if with.id = TRUE:
sample.id
the sample ids used in the analysis
snp.id
the SNP ids used in the analysis
grm
the genetic relationship matrix
If with.id = FALSE, this function returns the genetic relationship matrix (GRM) without sample and SNP IDs.

References

Yang, J., Lee, S. H., Goddard, M. E. & Visscher, P. M. GCTA: a tool for genome-wide complex trait analysis. American journal of human genetics 88, 76-82 (2011).

Patterson, N., Price, A. L. & Reich, D. Population structure and eigenanalysis. PLoS Genet. 2, e190 (2006).

Zheng X, Weir BS. Eigenanalysis on SNP Data with an Interpretation of Identity by Descent. Theoretical Population Biology. 2015 Oct 23. pii: S0040-5809(15)00089-1. doi: 10.1016/j.tpb.2015.09.004. [Epub ahead of print]

Weir BS, Zheng X. SNPs and SNVs in Forensic Science. Forensic Science International: Genetics Supplement Series. 2015. doi:10.1016/j.fsigss.2015.09.106

See Also

snpgdsIndInb, snpgdsFst

Examples

Run this code
# 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