Skip to contents

combinePvalues() is an R port of the comb-p Stouffer-Liptak-Kechris (SLK) p-value correction step. For each locus, nearby loci within max_dist are collected, an autocorrelation-derived covariance term is computed from their genomic distances, and the local p-values are combined with the SLK z-score formula used by comb-p.

Usage

combinePvalues(
  pvals,
  positions,
  chr = NULL,
  ends = positions,
  max_dist = 1000,
  lag_step = 50,
  min_dist = 0,
  lags = NULL,
  acf = NULL,
  method = c("slk", "none", stats::p.adjust.methods),
  correlation = c("spearman", "pearson", "kendall"),
  transform = TRUE,
  partial = TRUE,
  p_floor = 9e-117,
  na_correlation = 0
)

Arguments

pvals

Numeric vector of p-values.

positions

Numeric vector of genomic positions, one per p-value.

chr

Optional chromosome vector. If NULL, all positions are treated as coming from the same chromosome.

ends

Optional end positions. Defaults to positions, which treats each locus as a single point.

max_dist

Maximum distance used for local SLK neighborhoods and ACF estimation when acf is not supplied. Default is 1000.

lag_step

Width of distance bins used to estimate the ACF when acf is not supplied. Default is 50.

min_dist

Lower bound of the first ACF distance bin. Default is 0.

lags

Optional numeric vector of lag breakpoints. If supplied, it overrides min_dist, max_dist, and lag_step for ACF estimation.

acf

Optional precomputed ACF table with lag minimum, lag maximum, and correlation columns.

method

Either "slk"/"none" to return SLK p-values, or any method accepted by stats::p.adjust() such as "fdr"/"BH" to adjust the SLK p-values.

correlation

Correlation method used for ACF estimation. Default is "spearman", matching comb-p.

transform

Logical. If TRUE, estimate correlations on -log10(p). Default is TRUE, matching comb-p.

partial

Logical. If TRUE, estimate each lag interval from only pairs in that interval. If FALSE, outer intervals include pairs from shorter distances as in comb-p's non-partial ACF mode.

p_floor

Minimum p-value used before q-normal transformation.

na_correlation

Correlation value used for ACF bins whose correlation cannot be estimated. Default is 0.

Value

A numeric vector in the same order as pvals. The estimated or supplied ACF is attached as the "acf" attribute, and the unadjusted SLK p-values are attached as "slk_pvalues" when method requests an additional multiple-testing adjustment.

Details

If acf is not supplied, lagged correlations are estimated from pvals and positions using comb-p's default convention of Spearman correlations on -log10(p). If acf is supplied, it should contain columns named lag_min, lag_max, and correlation, or have those values in its first three columns.

References

Pedersen BS, Schwartz DA, Yang IV, Kechris KJ. Comb-p: software for combining, analyzing, grouping and correcting spatially correlated P-values. Bioinformatics. 2012;28(22):2986-2988.

Examples

p <- c(0.01, 0.03, 0.4, 0.02)
pos <- c(100, 150, 900, 940)
combinePvalues(p, pos, max_dist = 100)