sHWE: Hardy-Weinberg Equilibrium in structure populations

View source: R/sHWE.R

sHWER Documentation

Hardy-Weinberg Equilibrium in structure populations

Description

Compute structural Hardy-Weinberg Equilibrium (sHWE) p-values on a SNP-by-SNP basis. These p-values can be aggregated to determine genome-wide goodness-of-fit for a particular value of d. See \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1101/240804")} for more details.

Usage

sHWE(X, LF, B, max_iter = 100, tol = 1e-10)

Arguments

X

A matrix of SNP genotypes, i.e. an integer matrix of 0's, 1's, 2's and NAs. BEDMatrix is supported. Sparse matrices of class Matrix are not supported (yet).

LF

matrix of logistic factors

B

number of null datasets to generate, B = 1 is usually sufficient. If computational time/power allows, a few extra B could be helpful

max_iter

Maximum number of iterations for logistic regression

tol

Tolerance value passed to trunc_svd() Ignored if X is a BEDMatrix object.

Value

a vector of p-values for each SNP.

Examples

# get LFs
LF <- lfa(hgdp_subset, 4)
# look at a small (300) number of SNPs for rest of this example:
hgdp_subset_small <- hgdp_subset[ 1:300, ]
gof_4 <- sHWE(hgdp_subset_small, LF, 3)
LF <- lfa(hgdp_subset, 10)
gof_10 <- sHWE(hgdp_subset_small, LF, 3)
hist(gof_4)
hist(gof_10)

StoreyLab/lfa documentation built on March 7, 2024, 9:59 p.m.