View source: R/fstruct_functions.R
Q_stat | R Documentation |
This function computes a statistical measure of ancestry variability, Fst/FstMax, for a Q matrix, the default output of population structure inference software programs such as STRUCTURE and ADMIXTURE. The function returns a named list containing the ratio Fst/FstMax as well as the values of Fst and FstMax.
Q_stat(Q, K = ncol(Q))
Q |
A dataframe, matrix, or array representing a Q matrix. Each row
represents an individual and the last |
K |
The number of ancestral clusters in the Q matrix. Each individual
must have |
Fst/FstMax is a statistic that takes a value of 0 when every individual in a population has identical ancestry, and a value of 1 when the ancestry is maximally variable (see *our paper* for more details). It is based on the population differentiation statistic Fst which, in its traditional application, is used to measure variability in allele frequencies
A named list of containing the following entries:
Fst
: Fst computed as if each individual is a population, and each ancestral cluster is an allele.
FstMax
: The maximum value of Fst (for fixed frequency of the most frequent allele, or, in the analogy, the membership of the most prevalent ancestral cluster).
ratio
: The ratio Fst/FstMax. We recommend that this statistic be used to quantify ancestry variability and to compare the variability of two or more Q matrices.
Q_stat(
# Make an example matrix of membership coefficients.
# Each row is an individual. Rows sum to 1.
Q = matrix(c(
.4, .2, .4,
.5, .3, .2,
.5, .4, .1,
.6, .1, .3,
.6, .3, .1
),
nrow = 5,
byrow = TRUE
),
K = 3
) # How many ancestry coefficients per individual?
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.