Random-effects meta-analysis over a subset of sLDSC traits
Source:R/sldscWrapper.R
sldscSubsetMeta.RdRe-run the random-effects meta-analysis (DerSimonian-Laird, via
metafor::rma) on a chosen subset of the per-trait standardised tables
produced by sldscPostprocessingPipeline – no regression is
re-run, only the already-standardised per-trait estimates are re-meta'd.
Powers a "meta on a subset of traits" workflow: pick traits, pick target
annotation categories, and get the per-category tau* / enrichment /
enrichstat meta results back.
Arguments
- postprocessResult
The list returned by
sldscPostprocessingPipeline. Must carry a$per_traitelement;$params$target_categoriesis used whentargetCategoriesisNULL.- subsetTraits
Character vector of trait ids to meta over; every id must be present in
postprocessResult$per_trait.- targetCategories
Optional character vector of target annotation names. Defaults to
postprocessResult$params$target_categories.
Value
A list with tau_star_single, tau_star_joint,
enrichment, and enrichstat; each is a per-category named list
of metaSldscRandom results.
Examples
mkRun <- function(cats) {
n <- length(cats)
list(categories = cats, tau = setNames(rep(1e-7, n), cats),
tauSe = setNames(rep(3e-8, n), cats),
enrichment = setNames(rep(2, n), cats),
enrichmentSe = setNames(rep(0.4, n), cats),
enrichmentP = setNames(rep(0.01, n), cats),
propH2 = setNames(rep(0.2, n), cats),
propSnps = setNames(rep(0.1, n), cats), h2g = 0.3,
tauBlocks = matrix(1e-7, 10, n, dimnames = list(NULL, cats)),
nBlocks = 10L)
}
annot <- data.frame(CHR = c(1, 1, 1, 2, 2, 2), SNP = paste0("rs", 1:6),
annot_A = c(1, 0, 1, 0, 1, 0), annot_B = c(2.1, 1.8, 2.5, 1.9, 2.3, 2))
frq <- data.frame(CHR = c(1, 1, 1, 2, 2, 2), SNP = paste0("rs", 1:6),
MAF = rep(0.2, 6))
mkTrait <- function() {
list(single = list(mkRun(c("annot_A_0", "baselineLD_0")),
mkRun(c("annot_B_0", "baselineLD_0"))),
joint = mkRun(c("annot_A_0", "annot_B_0", "baselineLD_0")))
}
traits <- setNames(list(mkTrait(), mkTrait()), c("traitX", "traitY"))
sd <- SldscData(annot = annot, frq = frq, traits = traits)
pp <- sldscPostprocessingPipeline(sd)
#> [sldsc] Computing M_ref...
#> [sldsc] M_ref = 6 (MAF cutoff 0.05)
#> [sldsc] Computing per-annotation sd...
#> [sldsc] sd computed for 2 annotation columns
#> [sldsc] Detecting binary vs continuous annotations...
#> [sldsc] Auto-detected 2 target categories
#> [sldsc] Detected 1 baseline annotations: baselineLD_0
#> [sldsc] Standardizing 2 traits...
#> [sldsc] Running random-effects meta across traits...
sldscSubsetMeta(pp, subsetTraits = "traitX")
#> $tau_star_single
#> $tau_star_single$annot_A_0
#> $tau_star_single$annot_A_0$mean
#> [1] NA
#>
#> $tau_star_single$annot_A_0$se
#> [1] NA
#>
#> $tau_star_single$annot_A_0$p
#> [1] NA
#>
#> $tau_star_single$annot_A_0$nTraits
#> [1] 0
#>
#> $tau_star_single$annot_A_0$traitsUsed
#> character(0)
#>
#> $tau_star_single$annot_A_0$tau2
#> [1] NA
#>
#>
#> $tau_star_single$annot_B_0
#> $tau_star_single$annot_B_0$mean
#> [1] NA
#>
#> $tau_star_single$annot_B_0$se
#> [1] NA
#>
#> $tau_star_single$annot_B_0$p
#> [1] NA
#>
#> $tau_star_single$annot_B_0$nTraits
#> [1] 0
#>
#> $tau_star_single$annot_B_0$traitsUsed
#> character(0)
#>
#> $tau_star_single$annot_B_0$tau2
#> [1] NA
#>
#>
#>
#> $tau_star_joint
#> $tau_star_joint$annot_A_0
#> $tau_star_joint$annot_A_0$mean
#> [1] NA
#>
#> $tau_star_joint$annot_A_0$se
#> [1] NA
#>
#> $tau_star_joint$annot_A_0$p
#> [1] NA
#>
#> $tau_star_joint$annot_A_0$nTraits
#> [1] 0
#>
#> $tau_star_joint$annot_A_0$traitsUsed
#> character(0)
#>
#> $tau_star_joint$annot_A_0$tau2
#> [1] NA
#>
#>
#> $tau_star_joint$annot_B_0
#> $tau_star_joint$annot_B_0$mean
#> [1] NA
#>
#> $tau_star_joint$annot_B_0$se
#> [1] NA
#>
#> $tau_star_joint$annot_B_0$p
#> [1] NA
#>
#> $tau_star_joint$annot_B_0$nTraits
#> [1] 0
#>
#> $tau_star_joint$annot_B_0$traitsUsed
#> character(0)
#>
#> $tau_star_joint$annot_B_0$tau2
#> [1] NA
#>
#>
#>
#> $enrichment
#> $enrichment$annot_A_0
#> $enrichment$annot_A_0$mean
#> [1] NA
#>
#> $enrichment$annot_A_0$se
#> [1] NA
#>
#> $enrichment$annot_A_0$p
#> [1] NA
#>
#> $enrichment$annot_A_0$nTraits
#> [1] 1
#>
#> $enrichment$annot_A_0$traitsUsed
#> [1] "traitX"
#>
#> $enrichment$annot_A_0$tau2
#> [1] NA
#>
#>
#> $enrichment$annot_B_0
#> $enrichment$annot_B_0$mean
#> [1] NA
#>
#> $enrichment$annot_B_0$se
#> [1] NA
#>
#> $enrichment$annot_B_0$p
#> [1] NA
#>
#> $enrichment$annot_B_0$nTraits
#> [1] 1
#>
#> $enrichment$annot_B_0$traitsUsed
#> [1] "traitX"
#>
#> $enrichment$annot_B_0$tau2
#> [1] NA
#>
#>
#>
#> $enrichstat
#> $enrichstat$annot_A_0
#> $enrichstat$annot_A_0$mean
#> [1] NA
#>
#> $enrichstat$annot_A_0$se
#> [1] NA
#>
#> $enrichstat$annot_A_0$p
#> [1] NA
#>
#> $enrichstat$annot_A_0$nTraits
#> [1] 1
#>
#> $enrichstat$annot_A_0$traitsUsed
#> [1] "traitX"
#>
#> $enrichstat$annot_A_0$tau2
#> [1] NA
#>
#>
#> $enrichstat$annot_B_0
#> $enrichstat$annot_B_0$mean
#> [1] NA
#>
#> $enrichstat$annot_B_0$se
#> [1] NA
#>
#> $enrichstat$annot_B_0$p
#> [1] NA
#>
#> $enrichstat$annot_B_0$nTraits
#> [1] 1
#>
#> $enrichstat$annot_B_0$traitsUsed
#> [1] "traitX"
#>
#> $enrichstat$annot_B_0$tau2
#> [1] NA
#>
#>
#>