Skip to contents

Estimate SNP heritability from GWAS summary statistics using one of four methods: S-LDSC, g-LDSC, LDER, or HDL/sHDL. Supplying annotations makes any of them stratified.

Usage

estimateH2(
  sumstats,
  ldRef,
  method = "lder",
  annotations = NULL,
  local = FALSE,
  ...
)

# S4 method for class 'GwasSumStats,LdStatistic'
estimateH2(
  sumstats,
  ldRef,
  method = "lder",
  annotations = NULL,
  local = FALSE,
  studyName = NULL,
  estimatorArgs = list()
)

Arguments

sumstats

A GwasSumStats object.

ldRef

An LdStatistic object (method-appropriate subclass): an LdScore for "sldsc" / "gldsc", an LdEigen for "lder" / "hdl". Build either from loaded LD with buildLdScore / buildLdEigen.

method

Character, one of "lder" (the default), "sldsc", "gldsc" or "hdl":

"sldsc"

Stratified LD score regression (Finucane et al. 2015): weighted least squares of \(\chi^2\) on LD scores. Needs only per-variant scores when unstratified, so it is the cheapest of the four and the only one that runs on a scores-only LdScore.

"gldsc"

Generalized LD score regression (Xiong et al. 2024): GLS using the full per-block LD matrices.

"lder"

LD eigenvalue regression (Song et al. 2022).

"hdl"

High-definition likelihood (Ning et al. 2020), stratified as sHDL. Models reference-panel noise explicitly, so it shrinks hard when nRef is small.

annotations

An AnnotationMatrix object, or NULL for unstratified estimation.

local

Logical, whether to compute per-block local estimates.

...

Additional method-specific arguments.

studyName

Character (length 1) or NULL. Restrict the selection to this study; NULL matches all studies.

estimatorArgs

Optional named list of estimator-specific options (lambda for lder / gldsc / hdl, nIter for sldsc).

Value

An H2Estimate object.

Examples

data(ldScoreExample)
# The estimators index the z-scores by the reference's own variant order,
# so build the sumstats from the reference rather than alongside it.
gr <- as(ldScoreExample, "GRanges")
set.seed(1)
S4Vectors::mcols(gr) <- S4Vectors::DataFrame(
  SNP = names(ldScoreExample),
  A1 = S4Vectors::mcols(ldScoreExample)$A1,
  A2 = S4Vectors::mcols(ldScoreExample)$A2,
  Z = rnorm(length(ldScoreExample)),
  N = 100000L)
panel <- readGenotypes(
  system.file("extdata", "toy_ref.bed", package = "pecotmr")
)
ss <- GwasSumStats(studyName = "trait1", entry = list(gr),
  genome = unique(unname(GenomeInfoDb::genome(ldScoreExample))),
  ldReference = panel)
estimateH2(ss, ldScoreExample, method = "sldsc")
#> H2Estimate for 'trait1' (method: sldsc)
#>   h2 = 0.0006 (SE = 0.0004)
#>   intercept = 0.8836 (SE = 0.1427)
#>   Local: FALSE, Enrichment: FALSE, annotationJackknifeCoefs: FALSE
#>   N SNPs: 1300