This function runs ADMIXTURE, taking either a gen_tibble or a file as an
input. This is a wrapper that runs ADMIXTURE from the command line, and reads
the output into R. It can run multiple values of k and multiple repeats for
each k.
Usage
gt_admixture(
x,
k,
n_runs = 1,
crossval = FALSE,
n_cores = 1,
seed = NULL,
conda_env = "auto"
)Arguments
- x
a
gen_tibbleor a character giving the path of the input PLINK bed file- k
an integer giving the number of clusters
- n_runs
the number of runs for each k value (defaults to 1)
- crossval
boolean, should cross validation be used to assess the fit (defaults to FALSE)
- n_cores
number of cores (defaults to 1)
- seed
the seed for the random number generator (defaults to NULL)
- conda_env
the name of the conda environment to use. "none" forces the use of a local copy, whilst any other string will direct the function to use a custom conda environment.
Value
an object of class gt_admix consisting of a list with the following
elements:
kthe number of clustersQa matrix with the admixture proportionsPa matrix with the allele frequenciesloga log of the output generated by ADMIXTURE (usually printed on the screen when running from the command line)cvthe cross validation error (ifcrossvalis TRUE)loglikthe log likelihood of the modelidthe id column of the inputgen_tibble(if applicable)groupthe group column of the inputgen_tibble(if applicable)
Details
This is a wrapper for the command line program ADMIXTURE. It can either use a binary present in the main environment, or use a copy installed in a conda environment.
References
Alexander, D.H., Novembre, J. and Lange, K. (2009) ‘Fast model-based estimation of ancestry in unrelated individuals’, Genome Research, 19(9), pp. 1655–1664. Available at: https://doi.org/10.1101/gr.094052.109.
Examples
# run the example only if we have the package installed
if (FALSE) { # \dontrun{
bed_file <-
system.file("extdata", "lobster", "lobster.bed", package = "tidypopgen")
lobsters <- gen_tibble(bed_file,
backingfile = tempfile("lobsters"),
quiet = TRUE
)
lobsters <- lobsters %>% group_by(population)
gt_admixture(lobsters,
k = 2:3, seed = c(1, 2),
n_runs = 2, crossval = TRUE
)
} # }
