PyPop.Homozygosity#
Computing homozygosity statistics on genotype or allele counts.
Classes#
Calculate homozygosity statistics. |
|
Compute homozygosity using the Ewens-Watterson-Slatkin "exact test". |
|
Compute pairwise homozygosity using the Ewens-Watterson-Slatkin. |
Functions#
|
Get homozygosity from allele data. |
Module Contents#
- class Homozygosity(alleleData, rootPath='.', debug=0)#
Calculate homozygosity statistics.
Given allele count data for a given locus, calculates the observed homozygosity and returns the approximate expected homozygosity statistics taken from previous simulation runs.
- Parameters:
- getObservedHomozygosity()#
Calculate and return observed homozygosity.
Available even if expected stats cannot be calculated.
- Returns:
observed homozygosity
- Return type:
- canGenerateExpectedStats()#
Can expected homozygosity stats be calculated?
Returns
1
if expected homozygosity statistics can be calculated. Should be called before attempting to get any expected homozygosity statistics.- Returns:
1
if can be calculated, otherwise0
- Return type:
- getPValueRange()#
Gets lower and upper bounds for p-value.
Only meaningful if
canGenerateExpectedStats()
returns true.- Returns:
(
lower
,upper
) bounds.- Return type:
- getCount()#
Number of runs used to calculate statistics.
Only meaningful if
canGenerateExpectedStats()
returns1
.- Returns:
number of runs
- Return type:
- getExpectedHomozygosity()#
Gets mean of expected homozygosity.
This is the estimate of the expected homozygosity. Only meaningful if
canGenerateExpectedStats()
returns true.- Returns:
mean of expected homozygosity
- Return type:
- getVarExpectedHomozygosity()#
Gets variance of expected homozygosity.
This is the estimate of the variance expected homozygosity. Only meaningful if
canGenerateExpectedStats()
returns true.- Returns:
variance of expected homozygosity
- Return type:
- getNormDevHomozygosity()#
Gets normalized deviate of homozygosity.
Only meaningful if
canGenerateExpectedStats()
returns true.- Returns:
normalized deviate of homozygosity
- Return type:
- serializeHomozygosityTo(stream)#
Serialize homozygosity to a stream.
- Parameters:
stream (XMLOutputStream) – stream to save to
- class HomozygosityEWSlatkinExact(alleleData=None, numReplicates=10000, debug=0)#
Bases:
Homozygosity
Compute homozygosity using the Ewens-Watterson-Slatkin “exact test”.
- Parameters:
- getHomozygosity()#
Get the homozygosity statistics.
- Returns:
- tuple consisting of:
theta
prob_ewens
prob_homozygosity
mean_homozygosity
obsv_homozygosity
var_homozygosity
- Return type:
- serializeHomozygosityTo(stream)#
Serialize homozygosity to a stream.
- Parameters:
stream (XMLOutputStream) – stream to save to
- returnBulkHomozygosityStats(alleleCountDict=None, binningMethod=None)#
Get bulk homozygosity statistics for multiple allele counts.
This function is designed to work with the
PyPop.RandomBinning
submodule.
- class HomozygosityEWSlatkinExactPairwise(matrix=None, numReplicates=10000, untypedAllele='****', debug=0)#
Compute pairwise homozygosity using the Ewens-Watterson-Slatkin.
- Parameters:
matrix (StringMatrix) – matrix with multiple loci columns for pairwise comparison
numReplicates (int, optional) – number or replicates for simulation.
untypedAllele (str, optional) – untyped allele
debug (int, optional) – flag to switch debugging on
- serializeTo(stream)#
Serialize to a stream.
- Parameters:
stream (XMLOutputStream) – stream to save to