File Exchange

image thumbnail

HWEtest

version 2.0.0.0 (63.5 KB) by Giuseppe Cardillo
Test if a locus is under Hardy Weinberg Proportion

1 Download

Updated 28 Apr 2018

GitHub view license on GitHub

The conditional probability, under the Hardy-Weinberg equilibrium, to obtain the sample X is compute as described by:
Howard Levene - "On a matching problem arising in genetics".
Annals of Mathematical Statistics. 1949; 20:91-94.
If the locus is biallelic, the function performs an Exact test, computing the p-value of all possible tables and the summing all p-value<=p(observed table) and plots a De Finetti's Diagram.
If the locus is m-allelic (m>2), the function uses a Monte Carlo conventional method to evaluate the p-value.

Syntax: pvalue=hwetest(x,verbose,delta,alpha)

Input: X - Genotype matrix. If the locus is biallelic, X is a vector x=[AA AB BB]; else if the locus is m-allelic X is a lower triangular matrix of size=[m m]. If X is not a lower triangular matrix it will be triangularized. VERBOSE (optional)- a logical variable to display more results and comments: 0=does not display (default) 1=display DELTA and ALPHA (optional)- If Monte Carlo method is used (if locus is more than bi-allelic), it is necessary to evaluate how many times the process must be reiterated to ensure that p-value is within DELTA units of the true one with (1-ALPHA)*100% confidence. (Default DELTA=ALPHA=0.01). Output: the probability that the population is in HWP the De Finetti's Diagram if the locus is biallelic if VERBOSE: Polymorphism Information Content (PIC) Matching probability Power of discrimination Power of exclusion Typical Paternity Index

Example: Run hwedemo

Created by Giuseppe Cardillo
giuseppe.cardillo-edta@poste.it

To cite this file, this would be an appropriate format: Cardillo G. (2007) HWtest: a routine to test if a locus is in Hardy Weinberg equilibrium (exact test). http://www.mathworks.com/matlabcentral/fileexchange/14425

Comments and Ratings (1)

Dmitriy Fradkin

This package has a nice demo, implements useful functionality, however it cannot be used inside other programs without further modifications to hwetest.
I would suggest adding a verbose flag to turn off all the printing, and making hwetest return some values.

Updates

2.0.0.0

inputparser; table implementation; elimination of ternplot and rewriting of some line of codes to plot De Finetti's diagram; github link

1.4.0.0

Changes in description

1.3.0.0

I'have added a statistical test on heterozigosity

1.2.0.0

changes in alpha and delta default values

1.1.0.0

Changes in help section

1.0.0.0

Improvement in input error handling

Added Polimorphism Information Content (PIC)

Added calculations for Matching probability, Power of discrimination; Power of exclusion; Typical Paternity Index

RANDPERM was replaced with the faster Fisher-Yates-Sattolo algorithm. NORMINV was replaced with ERFCINV function. The STATISTICS TOOLBOX is no more needed.
Correction was implemented for the De Finetti's diagram.
More comments added.

The function was heavly vectorized to speed up using the gammaln function. The waitbar was erased because it slacken the function too much.

some minor editing

fix a bug in De Finetti's diagram

Reinserting the verbose identifiler; added a De Finetti's Diagram for biallelic loci.

Monte Carlo method implemented

minor editing and inbreeding coefficient added

minor bug fixed

I erased the cloned code in the demo and added a "verbose" argument in

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: Fisherextest