# 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")
Run the code above in your browser using DataLab