
The sffdr package implements the surrogate functional false discovery
rate (sfFDR) procedure. This methodology integrates GWAS summary
statistics from related traits (i.e., pleiotropy) to increase
statistical power within the functional FDR framework. The inputs into
sffdr are a set of p-values from a GWAS of interest and a
set of p-values from one or many informative GWAS.
The significance quantities estimated by sffdr can be
used for a variety of analyses:
The methods implemented in this package are described in:
Bass AJ, Wallace C. Exploiting pleiotropy to enhance variant discovery with functional false discovery rates. Nature Computational Science; 2025.
Note that this work is an extension of the functional FDR methodology
and the software builds on some of the functions in the
fFDR package found at https://github.com/StoreyLab/fFDR.
To report any bugs or issues related to usage please report it on GitHub at https://github.com/ajbass/sffdr.
You can install the development version of sffdr from
GitHub:
# install development version of package
install.packages("devtools")
devtools::install_github("ajbass/sffdr")To demonstrate the package, we will use a sample dataset containing 10,000 SNPs for body mass index (BMI) as the primary trait of interest, with body fat percentage (BFP), cholesterol, and triglycerides as informative traits.
library(sffdr)
data(bmi)
# Define primary p-values and informative p-values
p <- sumstats$bmi
z <- as.matrix(sumstats[,-1])
head(sumstats)The first step is to model the relationship between the functional
proportion of null tests and the informative traits. We use
pi0_model to create a model and fpi0est to
estimate \(\pi_{0}(z)\).
# Create model: adaptively chooses knots at small quantiles where signal is expected
mpi0 <- pi0_model(z)
# Estimation of functional pi0
fpi0 <- fpi0est(p, mpi0)Note on Knots: Ideally, knots should cover the
distribution of non-null p-values in your informative studies. Our
algorithm uses an FDR threshold to choose the location of the knots and
the number of knots. Depending on the study, you may want to changes
these values (see ?pi0_model). Note that this toy example
contains only 10,000 p-values, so the knot locations are not optimal
since the function was designed for GWAS-scale data.
With the functional \(\pi_{0}\) estimated, we can now calculate the FDR quantities and functional p-values.
# Apply sfFDR
sffdr_out <- sffdr(p, fpi0 = fpi0$fpi0)
# Extract results
results <- data.frame(
p_value = p,
fp_value = sffdr_out$fpvalues,
fq_value = sffdr_out$fqvalues,
flfdr = sffdr_out$flfdr
)
# Plot significance results (focusing on high-significance SNPs)
plot(sffdr_out)In standard GWAS, SNPs are often correlated due to LD. To account for
this, you should provide a vector indicating which SNPs are
LD-independent (e.g., via pruning). sffdr uses these
independent SNPs to fit the model, then computes the significance
quantities for the entire dataset.
For GWAS, we recommend cross-fitting by chromosome (Liley and
Wallace, 2021). To do this, provide the chromosome labels in
folds: each SNP is then evaluated using a fit that excludes
its chromosome, i.e., leave-one-chromosome-out (LOCO). The
nfolds argument groups the chromosomes into fewer folds
(e.g., nfolds = 5) to reduce computation time, and
ncores runs the folds in parallel.
# Fit model using LD-independent subset (indep_snps: TRUE if SNP is LD-independent)
mpi0 <- pi0_model(z = z, indep_snps = indep_snps)
fpi0 <- fpi0est(p, mpi0, indep_snps = indep_snps)
# Recommended: cross-fit by chromosome (chr: the chromosome of each SNP)
sffdr_out <- sffdr(p, fpi0 = fpi0$fpi0, folds = chr, nfolds = 5)
# Without LD-independent SNPs (slower): pi0 is estimated in the same folds
fpi0 <- fpi0est(p, pi0_model(z = z), folds = chr, nfolds = 5)
sffdr_out <- sffdr(p, fpi0 = fpi0$fpi0, folds = chr, nfolds = 5)Note on folds: sffdr()
without folds (as in the quick start) is superseded by
cross-fitting by chromosome, which has better tail behavior under
LD.
Note on computational time: On a single core, LOCO
takes about 1 minute for 1 million SNPs and 7 minutes for 10 million. We
recommend nfolds = 5: in our simulations five folds
provided the same power as LOCO at genome-wide significance in a third
of the time. For low-powered studies, LOCO (the default) keeps more
power in the functional q-values.
Note on choosing independent SNPs: There are two
strategies: (1) prune using plink (e.g.,
--indep-pairwise 200kb 1 0.3) and use the pruned set of
SNPs as the independent set, or (2) use informed sampling of the
informative traits (e.g., clumping or based on LD blocks). The latter is
likely better when the primary study has low power.
If LD scores (\(l_{j}\)) are available (e.g., from LDSC regression), there are two ways to use them.
# LD score (log scale) added to the pi0 model built by pi0_model()
zt <- cbind(mpi0$zt, ld = log(ld_score))
fmod <- update(mpi0$fmod, ~ . + ns(ld, df = 3))
fpi0 <- fpi0est(p, z = zt, pi0_model = fmod, indep_snps = indep_snps)
sffdr_out <- sffdr(p, fpi0 = fpi0$fpi0, folds = chr, nfolds = 5)w <- 1 / ld_score
mpi0 <- pi0_model(z, weights = w)
fpi0 <- fpi0est(p, mpi0, weights = w)
sffdr_out <- sffdr(p, fpi0 = fpi0$fpi0, folds = chr, nfolds = 5)Note on incorporating LD scores: As LD scores are available for common reference panels (e.g., 1000 Genomes), they can be easily downloaded to use in sfFDR. If you have LD scores calculated from your data then that’s even better. However, it is problematic to use LD scores when the reference panel is not matched to your study population. In that case, the pruning (or informative sampling) strategy discussed above is the best option.
If the primary and informative studies share participants (e.g.,
traits measured in the same biobank), decorrelate the informative
studies with decorrelate_informative() and use its p-values
($p2) in pi0_model(). The primary p-values are
used unchanged (see ?decorrelate_informative).
When the informative variable is the expected \(\chi^{2}\) given functional annotations
(Bass et al. 2026), use pi0_model_echisq() in place of
pi0_model() (see ?pi0_model_echisq):
mpi0 <- pi0_model_echisq(echisq, indep_snps = indep_snps)
fpi0 <- fpi0est(p, mpi0, indep_snps = indep_snps)
sffdr_out <- sffdr(p, fpi0 = fpi0$fpi0, surrogate = echisq, folds = chr, nfolds = 5)Other annotations (e.g., the LD score or MAF) can be included as further columns:
mpi0 <- pi0_model_echisq(cbind(echisq = echisq, ld = ld_score), indep_snps = indep_snps)
fpi0 <- fpi0est(p, mpi0, indep_snps = indep_snps)
sffdr_out <- sffdr(p, fpi0 = fpi0$fpi0, folds = chr, nfolds = 5)The selection of knots in the B-spline basis is an important tuning parameter in sffdr. If your surrogate GWAS has extremely high power (very small p-values), we recommend placing more knots at the lower end of the p-value distribution to capture the local density of signals.
# Create model (can include other variables (e.g., MAF) or specify more complicated models)
fmod <- "~ns(bfp, knots = c(0.01, 0.025, 0.05, 0.1))"
fpi0_mod <- fpi0est(p = p,
z = mpi0$zt,
pi0_model = fmod)Note on incorporating additional variables: Other informative covariates can be included in the model (e.g., MAF, LD score, etc.). While the LD score annotations can be used (e.g., the baselineLD model), we have found that using the expected \(\chi^{2}\) given the annotations performs better in practice and simplifies the model fitting.