Learn R Programming

SNPRelate (version 1.6.4)

snpgdsPCACorr: PC-correlated SNPs in principal component analysis

Description

To calculate the SNP correlations between eigenvactors and SNP genotypes

Usage

snpgdsPCACorr(pcaobj, gdsobj, snp.id=NULL, eig.which=NULL, num.thread=1L, verbose=TRUE)

Arguments

pcaobj
the snpgdsPCAClass object returned from the function snpgdsPCA
gdsobj
an object of class SNPGDSFileClass, a SNP GDS file
snp.id
a vector of snp id specifying selected SNPs; if NULL, all SNPs are used
eig.which
a vector of integers, to specify which eigenvectors to be used
num.thread
the number of (CPU) cores used; if NA, detect the number of cores automatically
verbose
if TRUE, show information

Value

Return a list:
sample.id
the sample ids used in the analysis
snp.id
the SNP ids used in the analysis
snpcorr
a matrix of correlation coefficients, "# of eigenvectors" x "# of SNPs"

References

Patterson N, Price AL, Reich D (2006) Population structure and eigenanalysis. PLoS Genetics 2:e190.

See Also

snpgdsPCA, snpgdsPCASampLoading, snpgdsPCASNPLoading

Examples

Run this code
# open an example dataset (HapMap)
genofile <- snpgdsOpen(snpgdsExampleFileName())
# get chromosome index
chr <- read.gdsn(index.gdsn(genofile, "snp.chromosome"))

pca <- snpgdsPCA(genofile)
CORR <- snpgdsPCACorr(pca, genofile, eig.which=1:4)
plot(abs(CORR$snpcorr[3,]), xlab="SNP Index", ylab="PC 3", col=chr)

# close the file
snpgdsClose(genofile)

Run the code above in your browser using DataLab