Skip to contents

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 = "none"
)

Arguments

x

a gen_tibble or 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 ot 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:

  • k the number of clusters

  • Q a matrix with the admixture proportions

  • P a matrix with the allele frequencies

  • log a log of the output generated by ADMIXTURE (usually printed on the screen when running from the command line)

  • cv the cross validation error (if crossval is TRUE)

  • loglik the log likelihood of the model

  • id the id column of the input gen_tibble (if applicable)

  • group the group column of the input gen_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.