A Probabilistic Approach to Conducting PCA with Sparse Genotype Data from Ancient Samples
library(devtools)
install_github('sojwolf/ancientpca')
library(ancientpca)
R packages you need installed:
library(vcfR)
library(softImpute)
library(ggplot2)
library(ggrepel)
library(cowplot)
gt <- vcfToGenotypeMatrix(vcf_file="vcf_file.vcf", max_missing_snp=0.9, max_missing_sample=0.95)
gt_imputed <- impGenotypeMatrix(genotype_matrix=gt)
pca_gt <- prcomp(gt_imputed, center = TRUE, scale. = TRUE)
plotImpPCA(pca_obj=pca_gt, imputed_matrix=gt_imputed, original_matrix=gt, max_missing_snp=0.9, max_missing_sample=0.95,
meta_file = "meta.csv", output_pca_pdf = "output.pdf")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.