Hardy-Weinberg Equilibrium Calculator. Calculates the expected genotype frequencies based on the allele frequencies of a population in Hardy-Weinberg equilibrium.
Project description
Hardy Weinberg Equilibrium
Hardy-Weinberg Equilibrium Calculator. Calculates the expected genotype frequencies based on the allele frequencies of a population in Hardy-Weinberg equilibrium.
Installation
pip install hardyweinbergcalculator
Usage
usage: hwc [-h] [--version] [--verbose] [--debug] [--samples SAMPLES] [--p P] [--q Q] [--tpop TPOP] [--ppop PPOP] [--qpop QPOP] [--pq2pop PQ2POP] [--genes GENES [GENES ...]] [--json JSON [JSON ...]]
Hardy-Weinberg Equilibrium Calculator. Calculates the expected genotype frequencies based on the allele frequencies of a population in Hardy-Weinberg equilibrium. See: https://en.wikipedia.org/wiki/Hardy%E2%80%93Weinberg_principle
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
--verbose Enable verbose logging. (default: False)
--debug Enable debug logging. (default: False)
--samples SAMPLES Number of samples to generate, if using random data generator. (default: None)
--p P Frequency of dominant allele. (default: None)
--q Q Frequency of recessive allele. (default: None)
--tpop TPOP Total population. (default: None)
--ppop PPOP Original population of dominant allele. (default: None)
--qpop QPOP Original population of recessive allele. (default: None)
--pq2pop PQ2POP Original population of heterozygous allele. (default: None)
Example: python3 -m hwc --ppop 10 --qpop 10 --pq2pop 200 --verbose
Generate random data
python3 -m hwc --samples 1000 --verbose
Calculate from known data
python3 -m hwc --ppop 10 --qpop 10 --pq2pop 200 --verbose
In your code
Test for Hard-Weinberg Equilibrium from generated data
from hwc import generate_population, HardyWeinberg
# Generate random data
population = generate_population(n=1000)
res = HardyWeinberg(genes=population)
print(res)
Test for Hardy-Weinberg Equilibrium from known data
from hwc import HardyWeinberg
# Known data
res = HardyWeinberg(
homozygous_dominant_population=20,
homozygous_recessive_population=44,
heterozygous_population=95
)
print(res)
Results Data Object
The results returned from the Hardyweinberg test will ultimately look like this, in json format:
{
"2*pq": 0.375,
"@genes": [],
"chi_square_test": 1.1111111111111112,
"expected_heterozygous_population": 3.75,
"expected_homozygous_dominant_population": 5.625,
"expected_homozygous_recessive_population": 0.625,
"heterozygous_population": 5,
"homozygous_dominant_population": 5,
"homozygous_recessive_population": 0,
"p": 0.75,
"p + q": 1.0,
"p**2": 0.5625,
"p**2 + 2*pq + q**2": 1.0,
"q": 0.25,
"q**2": 0.0625,
"total_population": 10
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hardyweinbergcalculator-0.3.1.post20230614.zip.
File metadata
- Download URL: hardyweinbergcalculator-0.3.1.post20230614.zip
- Upload date:
- Size: 21.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
591fe3d5f8588b8f9b963db1ce416159ce823698b086101912422bca4d73be2b
|
|
| MD5 |
13aa66e57756b7fd7dff6f0e708cedeb
|
|
| BLAKE2b-256 |
61aa6aef5079f52b686cb1d4a830aca6efbd80c8123e599d1fa86a73fdd245f1
|
File details
Details for the file hardyweinbergcalculator-0.3.1.post20230614-py3-none-any.whl.
File metadata
- Download URL: hardyweinbergcalculator-0.3.1.post20230614-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca6b3096ac4b062f052051fdf3a03fdd4a4b2c60552424dcb01fccfe1a685fd9
|
|
| MD5 |
fbb39c699b7a2ed468ff42758573fa2c
|
|
| BLAKE2b-256 |
b687352999b587f108223f6e33c3b89aa452d0822c8c6ac717ada7a0092c5100
|