| gt_pcadapt | R Documentation |
gen_tibble objectpcadapt is an algorithm that detects genetic markers under selection. It is
based on the principal component analysis (PCA) of the genotypes of the
individuals. The method is described in Luu et al. (2017). See the R package
pcadapt, which provides extensive documentation and examples.
gt_pcadapt(x, pca, k, n_cores = 1, max_missing = 0.5)
x |
A |
pca |
a |
k |
Number of principal components to use in the analysis. |
n_cores |
Number of cores to use. |
max_missing |
the largest fraction of missing genotypes at a locus for
it to be tested (see Details); loci with more get |
Internally, this function uses the snp_pcadapt function from the bigsnpr
package.
The genotypes tested are those that the PCA was computed on:
with a PCA of genotypes with missing values (the default method of
gt_pca(), which compares individuals over the loci genotyped in both,
as PLINK does), the genotypes of x with their missing values; imputed
genotypes are not used.
with a PCA of complete or imputed genotypes, the imputed genotypes of
x if it has any (see gt_impute_simple(); they are used
automatically), and otherwise its genotypes with their missing values.
With missing genotypes, each locus is tested on the individuals genotyped
at it, as in the pcadapt package. Loci with more than a fraction
max_missing of their genotypes missing (by default, more than half), or
genotyped in fewer than 3 individuals (the minimum for a t-score), are not
tested, and get NA statistics: with few individuals genotyped, their
t-scores have heavy tails, which the normal approximation of bigsnpr
turns into tiny p-values at the top of the rankings of the loci.
Loci with the same genotype in every individual genotyped can not be tested, and give an error.
An object of subclass gt_pcadapt, a subclass of mhtest.
Luu, K., Bazin, E., & Blum, M. G. B. (2017). pcadapt: an R package to perform genome scans for selection based on principal component analysis. Molecular Ecology Resources, 17(1), 67–77. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/1755-0998.12592")}
bigsnpr::snp_pcadapt() which this function wraps.
# Create a gen_tibble of lobster genotypes
bed_file <-
system.file("extdata", "lobster", "lobster.bed", package = "tidypopgen")
lobsters <- gen_tibble(bed_file,
backingfile = tempfile("lobsters"),
quiet = TRUE
)
# Remove monomorphic loci
lobsters <- lobsters %>% select_loci_if(loci_maf(genotypes) > 0)
# Create PCA object (the lobsters have some missing genotypes, which do not
# need to be imputed)
pca <- gt_pca(lobsters)
# Create a gt_pcadapt object
gt_pcadapt(lobsters, pca, k = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.