Admixture¶
-
allel.
patterson_f2
(aca, acb)[source]¶ Unbiased estimator for F2(A, B), the branch length between populations A and B.
Parameters: - aca : array_like, int, shape (n_variants, 2)
Allele counts for population A.
- acb : array_like, int, shape (n_variants, 2)
Allele counts for population B.
Returns: - f2 : ndarray, float, shape (n_variants,)
Notes
See Patterson (2012), Appendix A.
-
allel.
patterson_f3
(acc, aca, acb)[source]¶ Unbiased estimator for F3(C; A, B), the three-population test for admixture in population C.
Parameters: - acc : array_like, int, shape (n_variants, 2)
Allele counts for the test population (C).
- aca : array_like, int, shape (n_variants, 2)
Allele counts for the first source population (A).
- acb : array_like, int, shape (n_variants, 2)
Allele counts for the second source population (B).
Returns: - T : ndarray, float, shape (n_variants,)
Un-normalized f3 estimates per variant.
- B : ndarray, float, shape (n_variants,)
Estimates for heterozygosity in population C.
Notes
See Patterson (2012), main text and Appendix A.
For un-normalized f3 statistics, ignore the B return value.
To compute the f3* statistic, which is normalized by heterozygosity in population C to remove numerical dependence on the allele frequency spectrum, compute
np.sum(T) / np.sum(B)
.
-
allel.
patterson_d
(aca, acb, acc, acd)[source]¶ Unbiased estimator for D(A, B; C, D), the normalised four-population test for admixture between (A or B) and (C or D), also known as the “ABBA BABA” test.
Parameters: - aca : array_like, int, shape (n_variants, 2),
Allele counts for population A.
- acb : array_like, int, shape (n_variants, 2)
Allele counts for population B.
- acc : array_like, int, shape (n_variants, 2)
Allele counts for population C.
- acd : array_like, int, shape (n_variants, 2)
Allele counts for population D.
Returns: - num : ndarray, float, shape (n_variants,)
Numerator (un-normalised f4 estimates).
- den : ndarray, float, shape (n_variants,)
Denominator.
Notes
See Patterson (2012), main text and Appendix A.
For un-normalized f4 statistics, ignore the den return value.
-
allel.
average_patterson_f3
(acc, aca, acb, blen, normed=True)[source]¶ Estimate F3(C; A, B) and standard error using the block-jackknife.
Parameters: - acc : array_like, int, shape (n_variants, 2)
Allele counts for the test population (C).
- aca : array_like, int, shape (n_variants, 2)
Allele counts for the first source population (A).
- acb : array_like, int, shape (n_variants, 2)
Allele counts for the second source population (B).
- blen : int
Block size (number of variants).
- normed : bool, optional
If False, use un-normalised f3 values.
Returns: - f3 : float
Estimated value of the statistic using all data.
- se : float
Estimated standard error.
- z : float
Z-score (number of standard errors from zero).
- vb : ndarray, float, shape (n_blocks,)
Value of the statistic in each block.
- vj : ndarray, float, shape (n_blocks,)
Values of the statistic from block-jackknife resampling.
See also
allel.stats.admixture.patterson_f3
Notes
See Patterson (2012), main text and Appendix A.
-
allel.
average_patterson_d
(aca, acb, acc, acd, blen)[source]¶ Estimate D(A, B; C, D) and standard error using the block-jackknife.
Parameters: - aca : array_like, int, shape (n_variants, 2),
Allele counts for population A.
- acb : array_like, int, shape (n_variants, 2)
Allele counts for population B.
- acc : array_like, int, shape (n_variants, 2)
Allele counts for population C.
- acd : array_like, int, shape (n_variants, 2)
Allele counts for population D.
- blen : int
Block size (number of variants).
Returns: - d : float
Estimated value of the statistic using all data.
- se : float
Estimated standard error.
- z : float
Z-score (number of standard errors from zero).
- vb : ndarray, float, shape (n_blocks,)
Value of the statistic in each block.
- vj : ndarray, float, shape (n_blocks,)
Values of the statistic from block-jackknife resampling.
See also
allel.stats.admixture.patterson_d
Notes
See Patterson (2012), main text and Appendix A.
-
allel.
moving_patterson_f3
(acc, aca, acb, size, start=0, stop=None, step=None, normed=True)[source]¶ Estimate F3(C; A, B) in moving windows.
Parameters: - acc : array_like, int, shape (n_variants, 2)
Allele counts for the test population (C).
- aca : array_like, int, shape (n_variants, 2)
Allele counts for the first source population (A).
- acb : array_like, int, shape (n_variants, 2)
Allele counts for the second source population (B).
- size : int
The window size (number of variants).
- start : int, optional
The index at which to start.
- stop : int, optional
The index at which to stop.
- step : int, optional
The number of variants between start positions of windows. If not given, defaults to the window size, i.e., non-overlapping windows.
- normed : bool, optional
If False, use un-normalised f3 values.
Returns: - f3 : ndarray, float, shape (n_windows,)
Estimated value of the statistic in each window.
-
allel.
moving_patterson_d
(aca, acb, acc, acd, size, start=0, stop=None, step=None)[source]¶ Estimate D(A, B; C, D) in moving windows.
Parameters: - aca : array_like, int, shape (n_variants, 2),
Allele counts for population A.
- acb : array_like, int, shape (n_variants, 2)
Allele counts for population B.
- acc : array_like, int, shape (n_variants, 2)
Allele counts for population C.
- acd : array_like, int, shape (n_variants, 2)
Allele counts for population D.
- size : int
The window size (number of variants).
- start : int, optional
The index at which to start.
- stop : int, optional
The index at which to stop.
- step : int, optional
The number of variants between start positions of windows. If not given, defaults to the window size, i.e., non-overlapping windows.
Returns: - d : ndarray, float, shape (n_windows,)
Estimated value of the statistic in each window.