hwe {SeqVarTools} | R Documentation

## Exact test for Hardy-Weinberg equilibrium

### Description

Performs an exact test for Hardy-Weinberg equilibrium on Single-Nucleotide Variants

### Usage

    ## S4 method for signature 'SeqVarGDSClass'
    hwe(gdsobj, permute=FALSE)

### Arguments

`gdsobj` | A `SeqVarGDSClass` object with VCF data.
`permute` | A logical indicating whether to permute the genotypes to get a set of p-values under the null hypothesis.

### Details

HWE calculations are performed with the `HWExact` function in the GWASExactHW package.

`permute=TRUE` will permute the genotypes prior to running the test. This can be useful for obtaining a set of expected values under the null hypothesis to compare to the observed values.

P values are set to `NA` for all multiallelic and monomorphic variants.

### Value

A data.frame with the following columns:

`variant.id` | The unique identifier for the variant
`nAA` | The number of reference homozygotes
`nAa` | The number of heterozygotes
`naa` | The number of alternate homozygotes
`afreq` | The reference allele frequency
`p` | p values for the exact test
`f` | The inbreeding coefficient, 1 - observed heterozygosity / expected heterozygosity

### Author(s)

Stephanie Gogarten

### See Also

`SeqVarGDSClass`, `applyMethod`

### Examples

    gds <- seqOpen(seqExampleFileName("gds"))
    ## autosomal variants only
    auto <- seqGetData(gds, "chromosome") %in% 1:22
    var.auto <- seqGetData(gds, "variant.id")[auto]
    hw <- applyMethod(gds, hwe, variant=var.auto)
    head(hw)
    sum(is.na(hw$p))
    range(hw$p, na.rm=TRUE)
    seqClose(gds)

[Package SeqVarTools version 1.24.1 Index]