pca_genos | R Documentation |
Takes a long-format data table of genotypes and conducts a PCA using R's
prcomp()
function. Different options for scaling the genotypes
pre-PCA are available.
pca_genos(
dat,
scaling = "covar",
sampCol = "SAMPLE",
locusCol = "LOCUS",
genoCol = "GT",
popCol = NULL
)
dat |
Data table: A long-fomate data table. Genotypes can be coded as '/' separated characters (e.g. '0/0', '0/1', '1/1'), or integers of Alt allele counts (e.g. 0, 1, 2). Must contain the following columns,
Optionally, a population ID column can also be included (see param |
scaling |
Character: How should the data (loci) be scaled?
Default is |
sampCol |
Character: The column name with the sampled individual information.
Default is |
locusCol |
Character: The column name with the locus information.
Default is |
genoCol |
Character: The column name with the genotype information.
Default is |
popCol |
Character: An optional argument. The column name with the
population information. Default is |
Returns a prcomp
object. If argument popCols
was specified,
and additional index of $pops
is also also present.
Patterson et al. (2006) Population structure and eigenanalysis. PLOS Genetics.
library(genomalicious)
# Data
data(data_Genos)
data_Genos
# Conduct the PCA with Patterson et al.'s (2006) normalisation, and
# population specified
pca <- pca_genos(dat=data_Genos, scaling='patterson', popCol='POP')
# Plot the PCA
pca_plot(pca)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.