# Class VcfHwe

java.lang.Object
org.snpsift.hwe.VcfHwe

public class VcfHwe extends Object
Calculate Hardy-Weimberg equilibrium and goodness of fit. References: "Principles of population genetics", Hartl invalid input: '&' Clark "A Note on Exact test of Hardy Weinbeg Equilibrium", G. Abecasis et. al. Note: This is only for two alleles in diploid individuals. We should extend this to more alleles and N-ploid species.

Author:
  pablocingolani

## Field Summary

Fields
Modifier and Type
Field
Description
`static boolean`
`debug`

## Constructor Summary

Constructors
Constructor
Description
`VcfHwe()`

## Method Summary

Modifier and Type
Method
Description
`double`
`hwe(org.snpeff.vcf.VcfEntry vcfEntry, boolean addInfo)`
Calculate Hardy-Weimberg equilibrium and add data to vcfEntry (INFO fields)
`double`
`hweLogPn12(int n1, int n2, int n12)`
Calculate exact log of "P[ n12 | n1, n2]" References: "Principles of population genetics", Hartl invalid input: '&' Clark, page 58 (formula 2.5) "A Note on Exact test of Hardy Weinbeg Equilibrium", G.
`double`
`hweP(int n1, int n2, int n12star)`
Calculate goodness of fit for n1, n2 combination.
`double`
`hwePchi2(int n1, int n2, int n12)`
Calculate goodness of fit using Chi square approximation
`double`
`hwePn12(int n1, int n2, int n12)`
Calculate exact probability of "P[ n12 | n1, n2]" References: "Principles of population genetics", Hartl invalid input: '&' Clark, page 58 (formula 2.5) "A Note on Exact test of Hardy Weinbeg Equilibrium", G.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### debug

public static boolean debug

## Constructor Details

### VcfHwe

public VcfHwe()

## Method Details

### hwe

public double hwe(org.snpeff.vcf.VcfEntry vcfEntry, boolean addInfo)
Calculate Hardy-Weimberg equilibrium and add data to vcfEntry (INFO fields)

Parameters:
  `addInfo` - : If true, 'HWE' and 'HWEP' INFO tags are added to this entry

### hweLogPn12

public double hweLogPn12(int n1, int n2, int n12)
Calculate exact log of "P[ n12 | n1, n2]" References: "Principles of population genetics", Hartl invalid input: '&' Clark, page 58 (formula 2.5) "A Note on Exact test of Hardy Weinbeg Equilibrium", G. Abecasis et. al. (formula 1)

Parameters:
  `n1` - : Number of 'A' alleles
  `n2` - : Number of 'B' alleles
  `n12` - : Number of 'AB' individuals Note: Total number of individuals (assuming they are diploid) is N = (n1 + n2) / 2
Returns:
  Log of pValue using exact test

### hweP

public double hweP(int n1, int n2, int n12star)
Calculate goodness of fit for n1, n2 combination. References: "Principles of population genetics", Hartl invalid input: '&' Clark, page 58 WARNING: The formula P_{HWE} in page 2 of "A Note on Exact test of Hardy Weinbeg Equilibrium", seems to have two mistakes (probably typos?)

### hwePchi2

public double hwePchi2(int n1, int n2, int n12)
Calculate goodness of fit using Chi square approximation

### hwePn12

public double hwePn12(int n1, int n2, int n12)
Calculate exact probability of "P[ n12 | n1, n2]" References: "Principles of population genetics", Hartl invalid input: '&' Clark, page 58 (formula 2.5) "A Note on Exact test of Hardy Weinbeg Equilibrium", G. Abecasis et. al. (formula 1)

Parameters:
  `n1` - : Number of 'A' alleles
  `n2` - : Number of 'B' alleles
  `n12` - : Number of 'AB' individuals Note: Total number of individuals (assuming they are diploid) is N = (n1 + n2) / 2
Returns:
  pValue using exact test