| Type: | Package |
| Title: | Surrogate Functional False Discovery Rates for Genome-Wide Association Studies |
| Version: | 1.2.5 |
| Maintainer: | Andrew Bass <ajb785@miami.edu> |
| Description: | Pleiotropy-informed significance analysis of genome-wide association studies with surrogate functional false discovery rates (sfFDR). The sfFDR framework adapts the fFDR to leverage informative data from multiple sets of GWAS summary statistics to increase power in study while accommodating for linkage disequilibrium. sfFDR provides estimates of key FDR quantities in a significance analysis such as the functional local FDR and $q$-value, and uses these estimates to derive a functional $p$-value for type I error rate control and a functional local Bayes' factor for post-GWAS analyses (e.g., fine mapping and colocalization). |
| URL: | https://github.com/ajbass/sffdr |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| VignetteBuilder: | knitr |
| LazyData: | true |
| Depends: | R (≥ 4.1.0) |
| Imports: | locfit, splines, ggplot2 (≥ 3.5.1), patchwork (≥ 1.3.0), qvalue, fastglm, withr, Rcpp, parallel |
| LinkingTo: | Rcpp |
| Suggests: | testthat (≥ 3.0.0), knitr, rmarkdown |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | yes |
| Packaged: | 2026-11-25 18:16:32 UTC; andrewbass |
| Author: | Andrew Bass [aut, cre], Chris Wallace [aut] |
| Repository: | CRAN |
| Date/Publication: | 2026-11-26 08:40:02 UTC |
sffdr: Surrogate Functional False Discovery Rate
Description
Estimate functional p-values, q-values, and local false discovery rates for GWAS data using summary statistics of related traits. The surrogate functional FDR (sfFDR) methodology extends the functional FDR framework to leverage informative covariates (e.g., functional annotations, GWAS summary statistics) for increased power while controlling false discovery rates.
Main Functions
pi0_modelBuild spline model for functional pi0 with adaptive knot selection
fpi0estEstimate functional pi0 using GLM with constrained binomial
sffdrCompute functional p-values, q-values, and local FDRs
plot.sffdrVisualize sfFDR results
Workflow
Prepare informative variables (i.e., p-values from related GWAS)
Build functional pi0 model:
mpi0 <- pi0_model(z)Estimate functional pi0:
fpi0 <- fpi0est(p, z = mpi0$zt, pi0_model = mpi0$fmod)Apply sfFDR:
sffdr_out <- sffdr(p, fpi0 = fpi0$fpi0)Visualize:
plot(sffdr_out)
Author(s)
Andrew J. Bass
See Also
pi0_model, fpi0est, sffdr, plot.sffdr
Subset of p-values from the UK Biobank
Description
A dataset containing a subset of p-values from the UK Biobank.
Format
A data frame with 10,000 rows and 4 columns:
- bmi
Body mass index
- bfp
Body fat percentage
- cholesterol
Cholesterol
- triglycerides
Triglycerides
Examples
# Import data
data(bmi)
# Separate main p-values and informative p-values
p <- sumstats$bmi
z <- as.matrix(sumstats[, -1])
Decorrelate the informative studies from the primary study
Description
When the primary study shares samples with the informative studies, their
null z-scores are correlated. Used as covariates in pi0_model,
the informative p-values then predict the primary's null tests, which
inflates false discoveries. decorrelate_informative() removes the
primary's noise from each informative study,
u_k = (z_k - r_k z_1) / \sqrt{1 - r_k^2},
where r_k is the null correlation of study k with the primary.
Under the primary's null, u is independent of z_1 whatever the
informative studies' effects, so the primary's p-values are analysed
unchanged with the decorrelated p-values as covariates.
Usage
decorrelate_informative(
z_x,
z_y,
p_x = NULL,
p_y = NULL,
rho_o = NULL,
lfdr_x = NULL,
indep_snps = NULL
)
Arguments
z_x |
Numeric vector; the primary study's z-scores. |
z_y |
Numeric vector or matrix; signed z-scores of the informative
studies (one column per study), in the same order as |
p_x, p_y |
Ignored; kept for compatibility with sffdr 1.1.2. |
rho_o |
Optional overlap correlations of the primary with each
informative study (one number per study). If |
lfdr_x |
Ignored. sffdr 1.1.2 scaled the correction by the primary's local FDR, which left part of the overlap in the covariates. |
indep_snps |
Optional logical or integer vector selecting approximately
independent SNPs, used to estimate |
Details
The correction needs only the overlap correlation of each informative study
with the primary: cross-trait LD score regression intercepts are the
recommended source for GWAS; otherwise they are estimated by
estimate_overlap. Errors in them enter at second order: in
simulations, a correlation of 0.5 given as 0.35 or 0.65 left the FDR within
0.005 of its value at the true correlation.
Value
A list with
- z2
decorrelated z-scores of the informative studies (vector or matrix, as
z_y)- p2
their p-values, for use as covariates
- rho_o
the overlap correlations used
See Also
Examples
set.seed(1)
n <- 20000
e1 <- rnorm(n)
e2 <- 0.5 * e1 + sqrt(1 - 0.5^2) * rnorm(n)
z_x <- e1 + ifelse(runif(n) < 0.05, 3, 0) # primary
z_y <- e2 + ifelse(runif(n) < 0.1, 3, 0) # informative, same samples
dec <- decorrelate_informative(z_x, z_y, rho_o = 0.5)
p_x <- 2 * pnorm(-abs(z_x))
mpi0 <- pi0_model(as.matrix(dec$p2))
fpi0 <- fpi0est(p_x, pi0_model_obj = mpi0)
res <- sffdr(p_x, fpi0 = fpi0$fpi0)
Estimate the overlap correlation between studies
Description
Estimates the null correlation of z-scores between studies that share
samples, for every pair of cbind(z, z_informative). For each pair it
uses the mean product of z-scores inside the box |z_1|, |z_2| < t,
which is unaffected by signal present in only one of the two studies, and
inverts it through the exact truncated bivariate normal moment. Cross-trait
LD score regression intercepts are preferable for GWAS when available.
Usage
estimate_overlap(z, z_informative, indep_snps = NULL, threshold = 1.5)
Arguments
z |
Numeric vector; the primary study's z-scores. |
z_informative |
Numeric vector or matrix of the informative studies' z-scores. |
indep_snps |
Optional logical or integer vector of approximately independent SNPs to use. |
threshold |
Numeric; the box half-width |
Value
The (K+1) \times (K+1) correlation matrix, primary first.
See Also
Fit Bivariate Density with Adaptive Downsampling
Description
Internal helper for 2D kernel density estimation with signal prioritization.
Usage
fit_bivariate_density(
train_s,
tail_threshold,
target_null,
nn,
maxit,
maxk,
weights = NULL,
verbose = TRUE,
tail_box = NULL,
...
)
Arguments
train_s |
2-column matrix on probit scale (covariate, p-values). |
tail_threshold |
Threshold on the probit p-values for the signal tail. |
target_null |
Maximum null SNPs to retain after downsampling. |
nn |
Nearest-neighbor bandwidth (NULL for automatic). |
maxit |
Maximum iterations for locfit. |
maxk |
Space for locfit's evaluation structure. |
weights |
Optional numeric vector of weights for density estimation. |
verbose |
Logical; whether to print progress messages during fitting. |
tail_box |
Optional probit p-value: fit only the surface below it
(cross-fitting's per-fold refit, the bulk coming from one fit on every
SNP), with the same rows and window; the fit's |
... |
Additional arguments for locfit(). |
Value
Fitted locfit object.
Fit locfit with Multiple Fallback Strategies
Description
Internal helper function that attempts to fit a locfit model using multiple strategies with different kernels, degrees, and smoothing parameters.
Usage
fit_strategy_final(
data,
valid_data,
nn_high,
nn_safe,
h_safe,
maxit,
maxk,
verbose,
ev = rbox(),
...
)
Arguments
data |
Data frame with columns V1, V2, and w (weights). |
valid_data |
Subset of data used for validation (typically signal-rich region). |
nn_high |
First (higher resolution) nn value to try. |
nn_safe |
Second (safer, more conservative) nn value. |
h_safe |
Constant bandwidth component. |
maxit |
Maximum iterations for locfit. |
maxk |
Space for locfit's evaluation structure. |
verbose |
Logical; print progress messages. |
ev |
locfit's evaluation structure (the tree on the data's box). |
... |
Additional arguments passed to locfit(). |
Value
A fitted locfit object; an error with the last message if every strategy fails.
Fit Univariate Density
Description
Internal helper for 1D kernel density estimation.
Usage
fit_univariate_density(train_s, nn, maxit, maxk, weights = NULL, ...)
Arguments
train_s |
Numeric vector on probit scale (distinct values). |
nn |
Nearest-neighbor bandwidth (NULL for automatic). |
maxit |
Maximum iterations for locfit (at most 20 are used). |
maxk |
Space for locfit's evaluation structure. |
weights |
Optional numeric vector of weights (multiplicities). |
... |
Additional arguments for locfit(). |
Value
Fitted locfit object.
Estimate Functional Proportion of Null Tests
Description
Estimates the functional proportion of null tests (pi0) using a GLM approach with a constrained binomial family. This function fits models across multiple lambda thresholds and selects the optimal estimate via MISE minimization.
Usage
fpi0est(
p,
pi0_model_obj = NULL,
z = NULL,
pi0_model = NULL,
indep_snps = NULL,
weights = NULL,
lambda = seq(0.05, 0.95, 0.05),
constrained.p = TRUE,
tol = 1e-09,
maxit = 60,
ncores = 1L,
verbose = TRUE,
folds = NULL,
nfolds = NULL,
...
)
Arguments
p |
Numeric vector of p-values. |
pi0_model_obj |
Optional list object returned by |
z |
Optional data frame or matrix of rank-transformed covariates.
Required if |
pi0_model |
Optional formula (as character string or formula object).
Required if |
indep_snps |
Optional independent SNPs for model fitting: a logical
vector with one entry per p-value, row indices, or SNP ids matched against
|
weights |
Optional numeric vector of weights in (0, 1], one per p-value, for the model fit. For GWAS data, this should be inverse LD scores (values above 1 are clamped to 1 with a warning). If these are available then you don't have to use the indep_snps argument, as the weights will effectively prioritize independent SNPs in the fitting process. |
lambda |
Numeric vector of lambda thresholds in (0, 1). Default is |
constrained.p |
Logical; use constrained binomial family. Default is TRUE. |
tol |
Numeric; convergence tolerance. Default is 1e-9. |
maxit |
Integer; maximum iterations of each fit, which also caps fastglm's step halvings. Default is 60. |
ncores |
Integer; number of cores for parallel lambda fitting via
|
verbose |
Logical; print progress messages. Default is TRUE. |
folds |
Optional vector of fold labels (e.g., chromosomes), one per
p-value. If given, lambda is chosen once and each fold's pi0 comes from the
model refitted on the other folds, so a SNP's pi0 does not use its own
p-value or its LD neighbours'. The fold models are kept with the estimates,
and |
nfolds |
Optional integer; with |
... |
Additional arguments passed to |
Details
Algorithm:
For each lambda threshold, fit a binomial GLM:
P(p \ge \lambda | z)Use constrained binomial family to ensure predictions in (0, 1)
Select optimal lambda via MISE minimization
Usage Patterns:
Pattern 1 (Recommended): Use output from pi0_model
mpi0 <- pi0_model(z) # Clean syntax: fpi0_out <- fpi0est(p, mpi0)
Pattern 2: Manually specify formula and covariates
fpi0_out <- fpi0est(p, z = z_matrix, pi0_model = formula_obj)
Value
An object of class fpi0 (a list) containing:
- fpi0
Numeric vector of functional pi0 estimates for each test, floored at 0.01. Tests with a missing p-value or covariate get 1. With
folds, each test's estimate is from the model fitted without its fold, and the fold models are the attribute"pi0_folds". With one covariate in the model, the covariate is the attribute"surrogate",sffdr()'s default surrogate.- tableLambda
A data frame with one row per lambda value: the MISE, the mean fitted pi0 and whether it was chosen.
- MISE
The Mean Integrated Squared Error (MISE) at each lambda.
- lambda
The selected optimal lambda value.
- model
The fitted model at the selected lambda (class
fastglm2;predict()givesP(p \ge \lambda | z)).
Examples
# Import data
data(bmi)
# Separate main p-values and conditioning p-values
p <- sumstats$bmi
z <- as.matrix(sumstats[, -1])
# Apply pi0_model to create model (uses adaptive knot selection)
fmod <- pi0_model(z)
# Estimate functional pi0
fpi0_out <- fpi0est(p, fmod)
fpi0 <- fpi0_out$fpi0
# Apply sffdr
sffdr_out <- sffdr(p, fpi0)
Functional p-values
Description
Calculate functional p-values from functional local FDRs.
Usage
fpvalues(lfdr, p = NULL)
Arguments
lfdr |
A vector of functional local FDRs in [0, 1] (values above 1 are clamped to 1). |
p |
A vector of p-values for ranking purposes. Default is NULL. |
Details
Tests are ranked by lfdr, with ties broken by p. The
functional q-value of a test is the mean lfdr of the tests ranked at
or above it, and its functional p-value is the lfdr mass ranked at
or above it as a fraction of the total mass. Tests with identical
lfdr and p are one set: each receives the set's values, so
the result does not depend on the order of the input. When p is
NULL, ties are broken at random.
Value
A list containing:
fp |
Functional p-values. |
fq |
Functional q-values. |
Kernel Density Estimation for GWAS P-values
Description
Performs kernel density estimation on p-values (univariate) or joint p-value/covariate pairs (bivariate) using local regression on the probit scale. The estimator is optimized for GWAS data with linkage disequilibrium (LD) and uses adaptive downsampling to prioritize signal-rich regions while maintaining computational efficiency.
Usage
kernelEstimator(
x,
eval.points = x,
epsilon = .Machine$double.xmin,
epsilon.max = 1 - 1e-04,
maxk = 5000,
maxit = 200,
target_null = 1e+05,
trim = 0,
nn = NULL,
tail_threshold = -2,
weights = NULL,
verbose = TRUE,
...
)
Arguments
x |
Numeric vector of p-values (for 1D density) or a 2-column matrix where the first column contains an informative covariate/surrogate and the second column contains the p-values. All p-values must be in (0, 1) and the covariate/surrogate must be rank-transformed to be (0,1]. |
eval.points |
Points at which to evaluate the density estimate. Defaults to
|
epsilon |
Lower bound for p-values to prevent numerical issues. P-values
below this are clamped to |
epsilon.max |
Upper bound for p-values. P-values above this are clamped to
|
maxk |
Space allocated for |
maxit |
Maximum number of iterations for the bivariate local likelihood
fit. Default: |
target_null |
Maximum number of null SNPs to include in the weighted fit
(bivariate case only). SNPs in the signal-enriched tail (defined by
|
trim |
Numeric in [0, 1); if > 0, flattens the density for p-values in (1 - trim, 1) to reduce boundary artifacts from p-values artificially clumped near 1. Only applies to the p-value dimension. Default is 0 (no trimming). |
nn |
Nearest-neighbor bandwidth parameter for |
tail_threshold |
Threshold on the probit-transformed p-values
(bivariate case only). SNPs with |
weights |
Optional numeric vector of prior weights in (0, 1] for the fit (values above 1 are clamped to 1). |
verbose |
Logical; whether to print progress messages during fitting. Default is TRUE. |
... |
Additional arguments passed to |
Details
The function implements a multi-stage density estimation procedure:
-
Probit transformation: P-values are transformed to the normal scale via
qnormto stabilize variance and handle extreme values. -
Adaptive downsampling (bivariate only): To handle large GWAS datasets efficiently, the null region (p-values above the tail threshold) is downsampled to
target_nullSNPs, with inverse-probability weighting to preserve the density. Signal-enriched SNPs (tail) are always retained. -
Cascade fitting: Multiple fitting strategies are attempted in sequence, with decreasing resolution and increasing robustness, until a valid fit is obtained.
-
Jacobian correction: Density estimates are transformed back to the original p-value scale using the Jacobian of the probit transformation.
The nearest-neighbor bandwidth nn controls smoothing and LD robustness.
By default the window spans about 5000 of the rows the density is fitted on
(the tail plus up to target_null null SNPs), so the estimator averages
over multiple LD blocks (~30-50 blocks in European ancestry populations),
reducing spurious local structure while preserving true signal-covariate
relationships. Versions before 1.1.4 took the fraction relative to all SNPs,
which left about 600 neighbours at one million SNPs.
In the univariate case, tied values are collapsed into one point with the corresponding multiplicity before fitting.
Value
A data frame with columns:
- x
Evaluation points (original scale).
- fx
Estimated density at evaluation points (original scale).
- s
Evaluation points on probit scale (
qnorm(x)).- fs
Estimated density on probit scale.
The returned object has an attribute "lfit" containing the fitted
locfit object for diagnostics.
See Also
Examples
## Not run:
# 1D density estimation
p <- runif(10000, 0, 1)
dens <- kernelEstimator(p)
plot(dens$x, dens$fx, type = "l")
# 2D density: the covariate (rank-transformed) first, the p-values second
p <- runif(10000, 0, 1)
z <- runif(10000)
x_mat <- cbind(z, p)
dens <- kernelEstimator(x_mat)
## End(Not run)
Fast Conditional Monotonic Smoothing
Description
Enforces strictly non-increasing density conditional on surrogate bins. Note: Data must be sorted by (group, pvalue) before passing.
Usage
monoSmooth_conditional(pvalue, density, group)
Arguments
pvalue |
Numeric vector of p-values. |
density |
Numeric vector of estimated densities. |
group |
Integer vector of surrogate bins. |
Value
A numeric vector of smoothed densities.
Fast Conditional PAVA (Decreasing)
Description
Fast Conditional PAVA (Decreasing)
Usage
monoSmooth_pava(pvalue, density, group)
Arguments
pvalue |
A numeric vector of p-values. Must be sorted ascendingly within each group. |
density |
A numeric vector of initial density estimates (e.g., from locfit). |
group |
An integer vector denoting the surrogate bin/stratum for each observation. |
Value
A numeric vector of smoothed, monotonically non-increasing densities.
Build Model for Functional Proportion of Null Tests (fpi0)
Description
Generates a natural spline model for the functional proportion of null tests (fpi0) by adaptively selecting knots based on an FDR threshold.
Usage
pi0_model(
z,
indep_snps = NULL,
weights = NULL,
fdr_threshold = 0.25,
min_discoveries = 150,
min_snps_per_knot = 100,
n_knots = 5,
verbose = TRUE,
seed = 2026
)
Arguments
z |
Numeric matrix/data.frame of p-values (rows=tests, cols=traits). |
indep_snps |
Independent SNPs (the training subset): a logical vector
with one entry per row of |
weights |
Optional numeric vector of weights in (0, 1] (e.g., inverse LD scores) for weighted spline fitting. Default: NULL. |
fdr_threshold |
FDR threshold for signal definition. Default: 0.25. |
min_discoveries |
Min (LD-independent) significant hits required to place a trait's knots from its discoveries; with fewer, the trait keeps a single fallback knot. Default: 150. |
min_snps_per_knot |
Base minimum significant SNPs per knot interval. Default: 100. Dynamically scales up for larger datasets to prevent overfitting. |
n_knots |
Target knot count. Default: 5. Automatically reduced if insufficient
discoveries (via |
verbose |
Print selection details. Default: TRUE. |
seed |
Optional seed for reproducibility. Default: 2026. |
Details
Independent SNPs determine knot placement; all SNPs train the model to capture signal shape.
For smaller datasets (<100K), consider reducing min_snps_per_knot and min_discoveries to improve knot placement.
Every column must hold p-values: the knots of a column are placed at the
quantiles of its discoveries (qvalue at
fdr_threshold), and a column with values outside [0, 1] gets the
fallback knot with a warning. A null anchor knot at rank 0.1 is always
added.
Value
List containing:
fmod |
Model formula (using |
zt |
Data frame of globally rank-transformed p-values |
Build the fpi0 Model for an Expected Chi-Squared Covariate
Description
Builds the natural-spline model for the functional proportion of null tests
(fpi0) when the informative variable is an expected chi-squared statistic
per SNP, such as a prediction of E[\chi^2] from functional annotations
(the LD-score regression fit of Bass et al., 2026), rather than a p-value.
It is the companion of pi0_model for this kind of covariate:
the output goes to fpi0est in the same way, and the covariate
itself serves as the surrogate of sffdr.
Usage
pi0_model_echisq(
x,
indep_snps = NULL,
weights = NULL,
null_value = 1,
knots = c(0.5, 0.75, 0.9, 0.95, 0.99, 0.999),
min_snps_per_knot = 100,
verbose = TRUE,
seed = 2026
)
Arguments
x |
Numeric vector, matrix or data frame of expected chi-squared
statistics (rows = tests, one column per prediction). Further columns can
be annotations (e.g., the LD score, MAF, annotation LD scores): each
column gets its own spline. Any scale is accepted; only the ranks are
modelled, and |
indep_snps |
Independent SNPs (the training subset): a logical vector
with one entry per row of |
weights |
Optional numeric vector of weights in (0, 1] (e.g., inverse LD scores); a bin's support is then its total weight. Default: NULL. |
null_value |
The value of the covariate under no association, where the anchor knot is placed. Default: 1, the expectation of a chi-squared statistic with one degree of freedom under the null. |
knots |
Candidate knots, as quantiles of the rank of |
min_snps_per_knot |
Minimum number of independent SNPs (or total weight) between consecutive knots. Default: 100. |
verbose |
Print the knots kept for each column. Default: TRUE. |
seed |
Seed for the random tie-breaking of the ranks. Default: 2026. |
Details
A p-value covariate puts its signal at rank 0, and pi0_model
places its knots at the quantiles of that column's discoveries. An expected
chi-squared puts its signal at the top and has a known null value: with no
association E[\chi^2] = 1, so SNPs predicted at or below
null_value carry no information and the proportion of nulls is flat
there. The model is a natural spline in the rank of the covariate (so its
scale is immaterial) with one knot anchored at the rank of
null_value, i.e. the share of SNPs predicted at or below it, and the
remaining knots at fixed upper quantiles of the rank, where the proportion
of nulls changes. Candidate knots at or below the anchor are dropped.
Knots are then removed, sparsest bin first, until every bin between
consecutive knots holds at least min_snps_per_knot independent SNPs
(or that much weight), so no spline coefficient rests on a handful of SNPs;
the anchor is kept while a neighbouring knot can go instead. The anchor is
used only when null_value sits inside the covariate's range (rank
between 0.01 and 0.99): a covariate on another scale, or one predicted
above 1 everywhere, gets the quantile knots alone, with a message, which is
how an annotation column is handled. With a single column the covariate is
also the natural surrogate for sffdr; with several,
use the estimated fpi0 (the default of sffdr).
Value
List containing:
fmod |
Model formula (using |
zt |
Data frame of rank-transformed covariates |
knots |
List of the knots kept, per column, on the rank scale |
anchor |
Named numeric vector: the rank of |
References
Bass AJ, Park J, Mukherjee S, Whittaker JC, Wallace C (2026). Genomic foundation models do not yet boost common variant discovery beyond standard functional annotations. bioRxiv.
See Also
Examples
set.seed(1)
n <- 20000
a <- rnorm(n)
echisq <- 1 + exp(a) / 4
nonnull <- runif(n) < plogis(-4 + a)
z <- rnorm(n) + ifelse(nonnull, rnorm(n, 0, 3), 0)
p <- 2 * pnorm(-abs(z))
mod <- pi0_model_echisq(echisq, verbose = FALSE)
fpi0 <- fpi0est(p, pi0_model_obj = mod, verbose = FALSE)$fpi0
cor(fpi0, echisq) < 0
Plotting function for sffdr object
Description
Graphical display of the sffdr object
Usage
## S3 method for class 'sffdr'
plot(x, rng = c(0, 5e-08), ...)
Arguments
x |
A sffdr object. |
rng |
Significance region to show (functional p-value range). Optional. If no functional p-value falls in it, the range is widened to the smallest one percent. |
... |
Additional arguments. Currently unused. |
Value
Nothing of interest.
Author(s)
Andrew J. Bass
See Also
Examples
## Not run:
# import data
data(bmi)
# Separate main p-values and conditioning p-values
p <- sumstats$bmi
z <- as.matrix(sumstats[, -1])
# Apply pi0_model to create model
fmod <- pi0_model(z)
# Estimate functional pi0
fpi0_out <- fpi0est(p, z = fmod$zt, pi0_model = fmod$fmod)
fpi0 <- fpi0_out$fpi0
# Apply sffdr
sffdr_out <- sffdr(p, fpi0)
# Plot significance results
plot(sffdr_out, rng = c(0, 5e-4))
## End(Not run)
Surrogate Functional False Discovery Rate Analysis
Description
Estimate functional p-values, q-values, and local false discovery rates (lfdr) for GWAS data leveraging summary statistics from related traits. Functional p-values map from the functional q-value (FDR-based measure) to a p-value for type I error rate control, accounting for pleiotropy that impacts the prior probability of association.
Usage
sffdr(
p.value,
fpi0,
surrogate = NULL,
weights = NULL,
epsilon = .Machine$double.xmin,
nn = NULL,
monotone = TRUE,
monotone_method = c("min", "pava"),
fp_ties = TRUE,
seed = 2026,
keep_fit = FALSE,
folds = NULL,
nfolds = NULL,
ncores = 1L,
verbose = TRUE,
...
)
Arguments
p.value |
Numeric vector of p-values to analyze, in [0, 1]. Exact zeros are clamped to the smallest positive double with a warning; negative values are an error. |
fpi0 |
Numeric vector of functional pi0 estimates, obtained
from |
surrogate |
Optional numeric vector (same length as |
weights |
Ignored, with a warning (kept for compatibility with sffdr 1.1.2); see Details. |
epsilon |
Numeric; lower bound for p-value clamping during density estimation.
Default is |
nn |
Numeric; nearest-neighbor bandwidth for |
monotone |
Logical; if TRUE, enforces monotonicity of the estimated density with respect to p-values within bins of the surrogate variable. Default is TRUE. |
monotone_method |
Character; method for enforcing monotonicity. Options are "min" (running minimum) or "pava" (Pool Adjacent Violators Algorithm). Default is "min". We do not recommend "pava" for GWAS data sets due to LD, but it may be better for expression data. |
fp_ties |
Logical; whether to break ties in functional p-values using the original p-value ordering. Default is TRUE. |
seed |
Integer; random seed for reproducibility of rank tie-breaking, the jitter and the null downsampling in the density fit. Default is 2026. |
keep_fit |
Logical; if TRUE, the fitted density surface and the
surrogate bins are kept in the result (element |
folds |
Optional vector of fold labels (e.g., chromosomes), one per SNP.
If given, the density's tail (p < 0.1) is refitted leave-one-fold-out and
each SNP is scored on the fit that did not see its fold; |
nfolds |
Optional integer; with |
ncores |
Integer; number of cores for fitting folds in parallel
( |
verbose |
Logical; print progress messages. Default is TRUE. |
... |
Additional arguments passed to |
Details
The surrogate functional FDR (sfFDR) methodology extends the functional FDR framework to leverage multiple informative variables (e.g., functional annotations, GWAS summary statistics) for increased power while controlling false discovery rates.
Workflow:
Estimate functional pi0 (proportion of nulls) using
fpi0estCall
sffdr()with p-values and estimated functional pi0Use returned functional p-values/q-values/local FDRs for significance testing
Surrogate Variable:
If not specified, the surrogate is the covariate of the functional pi0 model
when it has one (fpi0est attaches it to its estimates), and the
estimated functional pi0 otherwise: the pi0 compresses several covariates
into one.
Weights and LD:
The joint density is estimated over all tested SNPs, which is the set the
functional p-values count errors in, so sffdr() no longer reweights
it. Inverse-LD weights change the density to that of independent signals;
because associated SNPs have larger LD scores, this biases the local FDR
(conservative with inverse-LD weights, anti-conservative with weights that
are larger at associated SNPs). LD scores carry information about
association, so their place is the functional pi0 model, as a covariate
(see the vignette); as inverse weights they remain available in
pi0_model and fpi0est in place of an LD-pruned
training set.
Perfect-LD copies:
SNPs with identical p-values are copies of one signal (perfect LD). Each
set of copies contributes one point to the density fit, and the density is
then evaluated for every SNP, so copies do not narrow the effective window
in the tail (which inflated functional p-values below 1e-3 before 1.1.4).
Rounded p-values tie between unrelated SNPs too, almost only in the bulk
of the distribution where values are dense per significant digit, and
collapsing those would distort the density; so identical p-values count as
copies only when they are at least half as common below p = 0.023 as above
it, which holds for LD copies and fails for rounding. The window itself
spans about 5,000 of the rows the density is fitted on; see
kernelEstimator.
Interpretation note: Functional p-values reflect the global ranking of all SNPs by the functional local FDR. A SNP with a small functional p-value but large flfdr (> 0.5) has weak individual evidence but ranks favorably relative to null SNPs. This happens when there is strong prior evidence (fpi0) of the SNP being non-null. Thus, users should also consider flfdr (and fqvalues) alongside fpvalues when assessing individual SNP evidence. SNPs with flfdr > 0.5 should be interpreted cautiously regardless of their functional p-value.
Cross-fitting: when the number of effective tests is much smaller than the
number of SNPs (e.g., imputed data), set folds to the chromosome
labels to obtain calibrated functional p-values from leave-one-chromosome-out
fits (cross-fitting as in Liley and Wallace, 2021); nfolds
groups the chromosomes into fewer folds. Each fold refits the density's
tail (p < 0.1), where a fold's own SNPs move the fit; the bulk above it is
one fit on every SNP. Without an LD-pruned set for the pi0 model, estimate
pi0 in the same folds (fpi0est(folds = )): each fold is then scored
with the pi0 model fitted without it, which gives every SNP its pi0 and,
unless surrogate is given, its surrogate rank (the tail is refitted
on those ranks, the bulk is one fit on the global model's). A SNP beyond
the smallest p-value of the other folds, where the fit has no data, is
ranked by its own p-value:
its bin's local FDR at that edge, falling in proportion to p.
Value
An S3 object of class "sffdr" containing:
call |
The function call. |
pvalues |
The p-values as analysed (exact zeros clamped). |
fpvalues |
Functional p-values. |
fqvalues |
Functional q-values. |
flfdr |
Functional local false discovery rates. |
fpi0 |
Functional pi0 estimates. |
fx |
Joint density estimates at observed (p-value, surrogate) pairs. |
fit |
With |
folds |
The fold labels used, if given ( |
Author(s)
Andrew J. Bass
See Also
fpi0est, plot.sffdr, kernelEstimator
Examples
## Not run:
# Import data
data(bmi)
# Separate main p-values and conditioning p-values
p <- sumstats$bmi
z <- as.matrix(sumstats[, -1])
# Apply pi0_model to create model
# (note: use indep_snps argument to specify independent SNPs for training)
fmod <- pi0_model(z)
# Estimate functional pi0
# (note: use indep_snps argument to specify independent SNPs for training)
fpi0_out <- fpi0est(p, fmod)
fpi0 <- fpi0_out$fpi0
# Apply sffdr
sffdr_out <- sffdr(p, fpi0)
# Plot significance results
plot(sffdr_out)
# Extract functional quantities
fp <- sffdr_out$fpvalues
fq <- sffdr_out$fqvalues
flfdr <- sffdr_out$flfdr
# Cross-fit by chromosome (recommended for imputed data); nfolds = 5 groups
# the chromosomes into five folds
sffdr_cv <- sffdr(p, fpi0, folds = chr)
## End(Not run)
Defunct functions in sffdr
Description
The earlier sample-overlap functions have been removed. Use
decorrelate_informative to correct for sample overlap with
the informative studies, and
estimate_overlap to estimate the overlap correlation.
Usage
overlap_null_density(...)
run_empirical_overlap_correction(...)
estimate_rho_overlap(...)
discover_empirical_nulls(...)
Arguments
... |
Ignored. |
Details
-
overlap_null_density: usedecorrelate_informative -
run_empirical_overlap_correction: usedecorrelate_informative -
estimate_rho_overlap: useestimate_overlap -
discover_empirical_nulls: useestimate_overlap