pval_gc: Apply genomic control transformation to a list of p-values

View source: R/pval_gc.R

pval_gcR Documentation

Apply genomic control transformation to a list of p-values

Description

Genomic control (GC) is a procedure designed to correct the calibration of p-values calculated from test statistics that are supposed to have a Chi-squared distribution but are misspecified and have a different median than desired, in which case the test statistics are divided by the inflation factor (the ratio between the observed and desired medians). This function applies the correction using p-values only, calculating the underlying test statistics assuming they are Chi-squared ditributed with known degrees of freedom. The function guarantees that the corrected p-values have a median of 0.5, as desired if they were calibrated, but otherwise there is no guarantee that these corrected p-values will have a reasonable distribution.

Usage

pval_gc(pvals, df = 1)

Arguments

pvals

The vector of association p-values to analyze. This function assumes all p-values are provided (a mix of null and alternative tests). NA values are allowed in input and removed. Non-NA values outside of [0, 1] will trigger an error.

df

The degrees of freedom of the assumed chi-squared distribution (default 1).

Value

A list with the following named elements:

  • pvals: the vector of GC-corrected p-values

  • lambda: the inflation factor of the input p-values, which was used to calculate the corrected p-values

See Also

pval_infl(), which is used internally to calculate the inflation factor.

Examples

# a simulated set of highly inflated p-values, skewed toward zero
pvals <- rbeta( 100, 1, 10 )
hist( pvals )

# calculate the GC-corrected p-values
obj <- pval_gc( pvals )
pvals2 <- obj$pvals
# and get the inflation factor of the original data:
obj$lambda

# note GC-corrected p-values are often not uniform:
hist( pvals2 )
# but they have a median of 0.5
median( pvals2 )


OchoaLab/simtrait documentation built on July 4, 2025, 3:48 a.m.