Skip to main content

A python package containing two statistical tests for HWE testing: Gibbs Sampling test and a modified Chi Squared test that handles ambiguity

Project description



python license

hwetests

Static Badge Static Badge

The Hardy-Weinberg Equilibrium (HWE) assumption is essential to many population genetics models, which assumes that allele pairs from a given population are random. An HWE test needs to test whether the pairing are random or not.

Our python package contains three statistical tests for HWE testing:

  • ASTA
  • UMAT
  • UMAT with sampling

Both ASTA and UMAT with sampling assume ambiguity in the observations while UMAT does not.

Table of Contents

Installation

Use the package manager pip to install hwetests.

pip install hwetests

Quick tour

To immediately use our package, you only need to run a single function.

ASTA

def full_algorithm(file_path,  
                   is_first_row_contains_columns_names=False,  
                   cutoff_value=0.0,  
                   should_save_csv=False,  
                   should_save_plot=False,  
                   title=''):

Suppose

Examples

Here we show how to use our package with simulated data. You can find the scripts and the simulated data in:

├───src
│   ├───test
│   │   ├───data
│   │   │   └───unambiguous_data.csv # for ASTA and UMAT with sampling (contains 50k population, 20 alleles, 0.2 uncertainty, in HWE)
│   │   │   └───ambiguous_data.csv # for UMAT (contains 100k population, in HWE)
│   │   ├───scripts
│   │   │   └───asta_test.py
│   │   │   └───umat_test.py
│   │   │   └───umat_with_sampling_test.py

ASTA test

from hwetests import asta  

if __name__ == '__main__':  
    p_value, statistic, dof = asta.full_algorithm(file_path='../data/ambiguous_data.csv',  
                                                  cutoff_value=4.0)  
    print(f'p-value: {p_value}')  
    print(f'statistic: {statistic}')  
    print(f'degrees of freedom: {dof}')

UMAT test

from hwetests import umat  
import numpy as np  

if __name__ == '__main__':  
    # import data from csv file as a numpy array  
    data = np.genfromtxt('../data/unambiguous_data.csv', delimiter=',')  
    # run the test  
    p_value = umat.full_algorithm(data)  
    print(f'p-value: {p_value}')

UMAT with sampling test

from hwetests import umat_with_uncertainty  

if __name__ == '__main__':  
    p_value = umat_with_uncertainty.full_algorithm(file_path='../data/ambiguous_data.csv')

License

asasda

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

hwetests-0.7.4.tar.gz (11.4 kB view hashes)

Uploaded Source

Built Distribution

hwetests-0.7.4-py3-none-any.whl (12.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page