exactHWE: Hardy-Weinberg Equilibrium testing

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/exactHWE.R

Description

This function performs exact Hardy-Weinberg Equilibrium testing (using Fisher's Test) over a selection of SNPs. It also counts genotype, calculates allele frequencies, and calculates inbreeding coefficients.

Usage

1
2
3
4
5
6
7
8
exactHWE(genoData, 		
         scan.exclude = NULL,
         geno.counts = TRUE,
         snpStart = NULL,
         snpEnd = NULL,
         block.size = 5000, 
         verbose = TRUE,
         permute = FALSE)

Arguments

genoData

a GenotypeData object

scan.exclude

a vector of scanIDs for scans to exclude

geno.counts

if TRUE (default), genotype counts are returned in the output data.frame.

snpStart

index of the first SNP to analyze, defaults to first SNP

snpEnd

index of the last SNP to analyze, defaults to last SNP

block.size

number of SNPs to read in at once

verbose

logical for whether to print status updates

permute

logical indicator for whether to permute alleles before calculations

Details

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

For the X chromosome, only female samples will be used in all calculations (since males are excluded from HWE testing on this chromosome). The X chromosome may not be included in a block with SNPs from other chromosomes. If the SNP selection includes the X chromosome, the scan annotation of genoData should include a "sex" column.

Y and M and chromsome SNPs are not permitted in the SNP selection, since the HWE test is not valid for these SNPs.

If permute=TRUE, alleles will be randomly shuffled before the HWE calculations. Running permutation can yield the expected distribution of p-values and corresponding confidence intervals.

Value

a data.frame with the following columns

snpID

the snpIDs

chr

chromosome SNPs are on

If geno.counts=TRUE:

nAA

number of AA genotypes in samples

nAB

number of AB genotypes in samples

nBB

number of BB genotypes in samples

MAF

minor allele frequency

minor.allele

which allele ("A" or "B") is the minor allele

f

the inbreeding coefficient

pval

exact Hardy-Weinberg Equilibrium (using Fisher's Test) p-value. pval will be NA for monomorphic SNPs (MAF=0).

Author(s)

Ian Painter, Matthew P. Conomos, Stephanie Gogarten, Adrienne Stilp

See Also

HWExact

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
library(GWASdata)
data(illuminaScanADF)

# run only on YRI subjects
scan.exclude <- illuminaScanADF$scanID[illuminaScanADF$race != "YRI"]

# create data object
gdsfile <- system.file("extdata", "illumina_geno.gds", package="GWASdata")
gds <- GdsGenotypeReader(gdsfile)
genoData <-  GenotypeData(gds, scanAnnot=illuminaScanADF)
chr <- getChromosome(genoData)

# autosomal SNPs
auto <- range(which(is.element(chr, 1:22)))
hwe <- exactHWE(genoData, scan.exclude=scan.exclude, 
                snpStart=auto[1], snpEnd=auto[2])

# permutation
perm <- exactHWE(genoData, scan.exclude=scan.exclude, 
                snpStart=auto[1], snpEnd=auto[2],
                permute=TRUE)

# X chromosome SNPs must be run separately since they only use females
Xchr <- range(which(chr == 23))
hweX <- exactHWE(genoData, scan.exclude=scan.exclude, 
                 snpStart=Xchr[1], snpEnd=Xchr[2])

close(genoData)

GWASTools documentation built on Nov. 8, 2020, 7:49 p.m.