snpgdsPCASampLoading {SNPRelate} | R Documentation |
To calculate the sample eigenvectors using the specified SNP loadings
snpgdsPCASampLoading(loadobj, gdsobj, sample.id=NULL, num.thread=1L, verbose=TRUE)
loadobj |
a |
gdsobj |
an object of class |
sample.id |
a vector of sample id specifying selected samples; if NULL, all samples are used |
num.thread |
the number of CPU cores used |
verbose |
if TRUE, show information |
The sample.id
are usually different from the samples used in the
calculation of SNP loadings.
Returns a snpgdsPCAClass
object, and it is a list:
sample.id |
the sample ids used in the analysis |
snp.id |
the SNP ids used in the analysis |
eigenval |
eigenvalues |
eigenvect |
eigenvactors, “# of samples” x “eigen.cnt” |
TraceXTX |
the trace of the genetic covariance matrix |
Bayesian |
whether use bayerisan normalization |
Or returns a snpgdsEigMixClass
object, and it is a list:
sample.id |
the sample ids used in the analysis |
snp.id |
the SNP ids used in the analysis |
eigenval |
eigenvalues |
eigenvect |
eigenvactors, “# of samples” x “eigen.cnt” |
afreq |
allele frequencies |
Xiuwen Zheng
Patterson N, Price AL, Reich D (2006) Population structure and eigenanalysis. PLoS Genetics 2:e190.
Zhu, X., Li, S., Cooper, R. S., and Elston, R. C. (2008). A unified association analysis approach for family and unrelated samples correcting for stratification. Am J Hum Genet, 82(2), 352-365.
snpgdsPCA
, snpgdsPCACorr
,
snpgdsPCASNPLoading
# open an example dataset (HapMap) genofile <- snpgdsOpen(snpgdsExampleFileName()) sample.id <- read.gdsn(index.gdsn(genofile, "sample.id")) PCARV <- snpgdsPCA(genofile, eigen.cnt=8) SnpLoad <- snpgdsPCASNPLoading(PCARV, genofile) # calculate sample eigenvectors from SNP loadings SL <- snpgdsPCASampLoading(SnpLoad, genofile, sample.id=sample.id[1:100]) diff <- PCARV$eigenvect[1:100,] - SL$eigenvect summary(c(diff)) # ~ ZERO # close the genotype file snpgdsClose(genofile)