Site frequency spectra¶

allel.stats.sf.
sfs
(dac)[source]¶ Compute the site frequency spectrum given derived allele counts at a set of biallelic variants.
Parameters: dac : array_like, int, shape (n_variants,)
Array of derived allele counts.
Returns: sfs : ndarray, int, shape (n_chromosomes,)
Array where the kth element is the number of variant sites with k derived alleles.

allel.stats.sf.
sfs_folded
(ac)[source]¶ Compute the folded site frequency spectrum given reference and alternate allele counts at a set of biallelic variants.
Parameters: ac : array_like, int, shape (n_variants, 2)
Allele counts array.
Returns: sfs_folded : ndarray, int, shape (n_chromosomes//2,)
Array where the kth element is the number of variant sites with a minor allele count of k.

allel.stats.sf.
sfs_scaled
(dac)[source]¶ Compute the site frequency spectrum scaled such that a constant value is expected across the spectrum for neutral variation and constant population size.
Parameters: dac : array_like, int, shape (n_variants,)
Array of derived allele counts.
Returns: sfs_scaled : ndarray, int, shape (n_chromosomes,)
An array where the value of the kth element is the number of variants with k derived alleles, multiplied by k.

allel.stats.sf.
sfs_folded_scaled
(ac, n=None)[source]¶ Compute the folded site frequency spectrum scaled such that a constant value is expected across the spectrum for neutral variation and constant population size.
Parameters: ac : array_like, int, shape (n_variants, 2)
Allele counts array.
n : int, optional
The total number of chromosomes called at each variant site. Equal to the number of samples multiplied by the ploidy. If not provided, will be inferred to be the maximum value of the sum of reference and alternate allele counts present in ac.
Returns: sfs_folded_scaled : ndarray, int, shape (n_chromosomes//2,)
An array where the value of the kth element is the number of variants with minor allele count k, multiplied by the scaling factor (k * (n  k) / n).

allel.stats.sf.
joint_sfs
(dac1, dac2)[source]¶ Compute the joint site frequency spectrum between two populations.
Parameters: dac1 : array_like, int, shape (n_variants,)
Derived allele counts for the first population.
dac2 : array_like, int, shape (n_variants,)
Derived allele counts for the second population.
Returns: joint_sfs : ndarray, int, shape (m_chromosomes, n_chromosomes)
Array where the (i, j)th element is the number of variant sites with i derived alleles in the first population and j derived alleles in the second population.

allel.stats.sf.
joint_sfs_folded
(ac1, ac2)[source]¶ Compute the joint folded site frequency spectrum between two populations.
Parameters: ac1 : array_like, int, shape (n_variants, 2)
Allele counts for the first population.
ac2 : array_like, int, shape (n_variants, 2)
Allele counts for the second population.
Returns: joint_sfs_folded : ndarray, int, shape (m_chromosomes//2, n_chromosomes//2)
Array where the (i, j)th element is the number of variant sites with a minor allele count of i in the first population and j in the second population.

allel.stats.sf.
joint_sfs_scaled
(dac1, dac2)[source]¶ Compute the joint site frequency spectrum between two populations, scaled such that a constant value is expected across the spectrum for neutral variation, constant population size and unrelated populations.
Parameters: dac1 : array_like, int, shape (n_variants,)
Derived allele counts for the first population.
dac2 : array_like, int, shape (n_variants,)
Derived allele counts for the second population.
Returns: joint_sfs_scaled : ndarray, int, shape (m_chromosomes, n_chromosomes)
Array where the (i, j)th element is the scaled frequency of variant sites with i derived alleles in the first population and j derived alleles in the second population.

allel.stats.sf.
joint_sfs_folded_scaled
(ac1, ac2, m=None, n=None)[source]¶ Compute the joint folded site frequency spectrum between two populations, scaled such that a constant value is expected across the spectrum for neutral variation, constant population size and unrelated populations.
Parameters: ac1 : array_like, int, shape (n_variants, 2)
Allele counts for the first population.
ac2 : array_like, int, shape (n_variants, 2)
Allele counts for the second population.
m : int, optional
Number of chromosomes called in the first population.
n : int, optional
Number of chromosomes called in the second population.
Returns: joint_sfs_folded_scaled : ndarray, int, shape (m_chromosomes//2, n_chromosomes//2)
Array where the (i, j)th element is the scaled frequency of variant sites with a minor allele count of i in the first population and j in the second population.

allel.stats.sf.
fold_sfs
(s, n)[source]¶ Fold a site frequency spectrum.
Parameters: s : array_like, int, shape (n_chromosomes,)
Site frequency spectrum
n : int
Total number of chromosomes called.
Returns: sfs_folded : ndarray, int
Folded site frequency spectrum

allel.stats.sf.
fold_joint_sfs
(s, m, n)[source]¶ Fold a joint site frequency spectrum.
Parameters: s : array_like, int, shape (m_chromosomes, n_chromosomes)
Joint site frequency spectrum.
m : int
Number of chromosomes called in the first population.
n : int
Number of chromosomes called in the second population.
Returns: joint_sfs_folded : ndarray, int
Folded joint site frequency spectrum.

allel.stats.sf.
scale_sfs
(s, copy=True)[source]¶ Scale a site frequency spectrum.
Parameters: s : array_like, int, shape (n_chromosomes,)
Site frequency spectrum.
copy : bool, optional
If False, apply scaling to s in place.
Returns: sfs_scaled : ndarray, int, shape (n_chromosomes,)
Scaled site frequency spectrum.

allel.stats.sf.
scale_sfs_folded
(s, n, copy=True)[source]¶ Scale a folded site frequency spectrum.
Parameters: s : array_like, int, shape (n_chromosomes//2,)
Folded site frequency spectrum.
n : int
Number of chromosomes called.
copy : bool, optional
If False, apply scaling to s in place.
Returns: sfs_folded_scaled : ndarray, int, shape (n_chromosomes//2,)
Scaled folded site frequency spectrum.

allel.stats.sf.
scale_joint_sfs
(s, copy=True)[source]¶ Scale a joint site frequency spectrum.
Parameters: s : array_like, int, shape (m_chromosomes, n_chromosomes)
Joint site frequency spectrum.
copy : bool, optional
If False, apply scaling to s in place.
Returns: joint_sfs_scaled : ndarray, int, shape (m_chromosomes, n_chromosomes)
Scaled joint site frequency spectrum.

allel.stats.sf.
scale_joint_sfs_folded
(s, m, n, copy=True)[source]¶ Scale a folded joint site frequency spectrum.
Parameters: s : array_like, int, shape (m_chromosomes//2, n_chromosomes//2)
Folded joint site frequency spectrum.
m : int
Number of chromosomes called in the first population.
n : int
Number of chromosomes called in the second population.
copy : bool, optional
If False, apply scaling to s in place.
Returns: joint_sfs_folded_scaled : ndarray, int, shape (m_chromosomes//2, n_chromosomes//2)
Scaled folded joint site frequency spectrum.