Description Usage Arguments Value Author(s) References See Also Examples
Perform tracy-widom tests on a set of eigenvalues to determine the number of
significative eigenvalues and calculate the percentage of variance explained
by each principal component. For an example, see pca
.
1 | tracy.widom (object)
|
object |
a pcaProject object. |
tracy.widom
returns a list containing the following components:
eigenvalues |
The sorted input vector of eigenvalues (by descreasing order). |
twstats |
The vector of tracy-widom statistics. |
pvalues |
The vector of p-values associated with each eigenvalue. |
effecn |
The vector of effective sizes. |
percentage |
The vector containing the percentage of variance explained by each principal component. |
Eric Frichot
Tracy CA and Widom H. (1994). Level spacing distributions and the bessel kernel. Commun Math Phys. 161 :289–309. Patterson N, Price AL and Reich D. (2006). Population structure and eigenanalysis. PLoS Genet. 2 :20.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # Creation of the genotype file "genotypes.lfmm"
# with 1000 SNPs for 165 individuals.
data("tutorial")
write.lfmm(tutorial.R,"genotypes.lfmm")
#################
# Perform a PCA #
#################
# run of PCA
# Available options, K (the number of PCs calculated),
# center and scale.
# Creation of genotypes.pcaProject - the pcaProject object.
# a directory genotypes.pca containing:
# Create files: genotypes.eigenvalues - eigenvalues,
# genotypes.eigenvectors - eigenvectors,
# genotypes.sdev - standard deviations,
# genotypes.projections - projections,
# Create a pcaProject object: pc.
pc = pca("genotypes.lfmm", scale = TRUE)
#############################
# Perform Tracy-Widom tests #
#############################
# Perfom Tracy-Widom tests on all eigenvalues.
# Create file: genotypes.tracyWidom - tracy-widom test information,
# in the directory genotypes.pca/.
tw = tracy.widom(pc)
# Plot the percentage of variance explained by each component.
plot(tw$percentage)
# Display the p-values for the Tracy-Widom tests.
tw$pvalues
# remove pca Project
remove.pcaProject("genotypes.pcaProject")
|
[1] "genotypes.lfmm"
[1] "******************************"
[1] " Principal Component Analysis "
[1] "******************************"
summary of the options:
-n (number of individuals) 50
-L (number of loci) 400
-K (number of principal components) 50
-x (genotype file) /work/tmp/genotypes.lfmm
-a (eigenvalue file) /work/tmp/genotypes.pca/genotypes.eigenvalues
-e (eigenvector file) /work/tmp/genotypes.pca/genotypes.eigenvectors
-d (standard deviation file) /work/tmp/genotypes.pca/genotypes.sdev
-p (projection file) /work/tmp/genotypes.pca/genotypes.projections
-s data centered and scaled
[1] "*******************"
[1] " Tracy-Widom tests "
[1] "*******************"
summary of the options:
-n (number of eigenvalues) 50
-i (input file) /work/tmp/genotypes.pca/genotypes.eigenvalues
-o (output file) /work/tmp/genotypes.pca/genotypes.tracywidom
[1] 8.000e-09 8.000e-09 8.000e-09 1.503e-04 3.152e-02 4.215e-01 6.565e-01
[8] 6.859e-01 6.738e-01 9.363e-01 7.937e-01 9.827e-01 9.709e-01 9.425e-01
[15] 9.240e-01 8.119e-01 9.734e-01 9.870e-01 9.996e-01 9.972e-01 9.973e-01
[22] 9.904e-01 9.959e-01 9.835e-01 9.953e-01 9.777e-01 9.801e-01 9.354e-01
[29] 8.465e-01 9.499e-01 8.092e-01 8.500e-01 7.492e-01 9.638e-01 9.114e-01
[36] 8.908e-01 9.402e-01 9.173e-01 7.407e-01 8.460e-01 8.067e-01 7.215e-01
[43] 4.396e-01 2.428e-01 6.246e-01 2.789e-01 6.168e-01 3.909e-01 7.257e-01
[1] TRUE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.