AdmixLocal: Forward-Backward algorithm for local admixture inference

View source: R/AdmixLocal.R

AdmixLocalR Documentation

Forward-Backward algorithm for local admixture inference

Description

This function performs local admixture inference for a selected individual

Usage

AdmixLocal(
  Geno,
  ResAdmixGlobal,
  Ind,
  P,
  GeneticMap,
  SmoothParam = 1,
  MaxRec = NULL,
  DistIntBounds = c(0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1),
  MinProp = 1e-06,
  EmisProbMaxPermut = 100L,
  NbThreads = 0L,
  Verbose = TRUE
)

Arguments

Geno

List of genotying matrices of size M (number of markers), with each matrix of dimension N(number of individuals) x L(number of alleles) whose elements consists of discrete or continuous dosages

ResAdmixGlobal

A list generated by the AdmixGlobal function

Ind

Name of the individual to be processed

P

Ploidy level of the individual (positive integer superior or equal to 2)

GeneticMap

Dataframe with three columns: Chromosome, Marker, and Distance, with M rows. Distances must be in centiMorgan

SmoothParam

Smoothing parameter corresponding to the number of generations since admixture

MaxRec

Maximum number of recombination between adjacent markers, used as an approximation for transition probabilities, in order to speed up calculations and limit memory usage. The approximation is disabled by default. Specify a positive integer between 1 and P to activate it, which overrides DistIntBounds.

DistIntBounds

Vector of bounds for genetic distance intervals, used as an approximation for transition probabilities, in order to speed up calculations and limit memory usage. To deactivate the approximation, set DistIntBounds=NULL.

MinProp

Minimum value for admixture proportion below which the contribution of the group is not considered for the individual (positive numeric value inferior to 1/K where K is the number of groups)

EmisProbMaxPermut

Maximum number of permutations involved in computing exact emission probability, otherwise an approximate emission probability is calculated, used as an approximation to speed up calculations. When continuous dosages are informed, the approximate emission probability is calculated.

NbThreads

Number of threads to be used (positive integer) with a default value of 0 setting automatically all threads available

Verbose

A boolean describing if detailed information should be printed

Details

The function AdmixLocal() performs local admixture inference from: (i) genotyping data (Geno) formatted as a list of matrices (one for each marker), (ii) a list (ResAdmixGlobal) generated by the global admixture function AdmixGlobal(), (iii) a genetic map dataframe (GeneticMap), (iV) the name of the individual to analyse (Ind), (v) the ploidy level of the individual (P).

The inference of the local admixture hidden Markov model is performed by calculating posterior probabilities and the Viterbi path, both available from the results. By default, all available threads/CPU cores are used but the number can be chosen using NbThreads.

The rate at which breakpoints between blocks of homogeneous ancestry occur per unit of genetic distance is defined as a smoothing parameter controlling the size of ancestry blocks (SmoothParam). The larger the value, the smaller the expected ancestry block size.

Two approximations exist for transition probabilities to speedup calculations: (i) the first consists of a simplification of genetic distances between adjacent marker where genetic distances (in cM) comprised within each of these intervals are averaged (DistIntBounds), (ii) the second consists of limiting the number of recombination authorized to move from one ancestry state to another between adjacent markers (MaxRec). When both arguments are specified as NULL, exact transition probabilities are calculated.

When allele dosages are discrete, the exact emission probability distribution function is calculated when the number of phased genotypes (i.e. permutations) that can be derived from the unphased allele dosage does not exceed a threshold defined by EmisProbMaxPermut. When number of permutations exceeds the threshold or when allele dosages are continuous (e.g. obtained from read depth ratios), an approximation of the emission probability distribution is calculated, which helps speeding up calculations.

When an individual has a very low global (genome-wide) admixture proportion for an ancestral group, this contribution can be considered negligible and discarded from the local admixture inference to speedup calculations. The minimum threshold can be set using MinProp.

Value

A list of four items: a list of size C (number of chromosomes) with ancestry dosage matrices obtained from the posterior distribution (Posterior), a list of size C with ancestry dosages obtained from the Viterbi algorithm (Viterbi), the log-likelihood value (LogLik), and a list of size C of vectors indicating what emission probability was computed at each marker (EmisProbType)

See Also

  • SimulatePop() to simulate a polyploid admixed population.

  • AdmixGlobal() to perform global (genome-wide) admixture inference and generate the ResAdmixGlobal object for the AdmixLocal() function.

  • LocalPlot() to generate a local admixture plot using the results from the AdmixLocal() function.

Examples

## Simulate Simulate a polyploid admixed population
DataSim <- SimulatePop(K=3L, N=10L, P=6L, M=50L, C=5L, L=10L, Seed=123, NbThreads=1)

## Perform global admixture inference
ResAdmixGlobal <- AdmixGlobal(Geno=DataSim$Geno, K=3, Verbose=FALSE, NbThreads=1)

## Perform local admixture inference for one individual
ResAdmixLocal <- AdmixLocal(Geno=DataSim$Geno, ResAdmixGlobal=ResAdmixGlobal, 
                            Ind="Ind4", P=6L, DataSim$GeneticMap, 
                            Verbose=FALSE, NbThreads=1)

## Posterior ancestry dosages for Chr1
head(ResAdmixLocal$Posterior$Chr1)

## Viterbi ancestry dosages for Chr1
head(ResAdmixLocal$Viterbi$Chr1)

## Log-likelihood
ResAdmixLocal$LogLik

## Type of emission probability for Chr1
head(ResAdmixLocal$EmisProbType$Chr1)

AdmixPoly documentation built on June 18, 2026, 1:06 a.m.