Standardize tau and compute EnrichStat for one polyfun run
Source:R/sldscWrapper.R
standardizeSldscTrait.RdApplies the Gazal standardization \(\tau^*_C = \tau_C \cdot sd_C \cdot M_{ref} / h^2_g\) to the point and to each jackknife block. For `mode = "single"`, additionally computes EnrichStat and back-solves its standard error from polyfun's reported `Enrichment_p` using \(|Z| = \Phi^{-1}(1 - p/2)\).
Usage
standardizeSldscTrait(
sldscData,
trait,
mode = c("single", "joint"),
idx = NULL,
sdAnnot,
MRef,
targetCategories = NULL
)Arguments
- sldscData
An
SldscDataobject (the run is pulled from it viagetTraitRun).- trait
Character. Trait name (a key of the SldscData traits list).
- mode
Character: `"single"` or `"joint"`.
- idx
Integer or NULL. For `mode = "single"`, which of the trait's single-target runs to standardize.
- sdAnnot
Named numeric vector from
computeSldscAnnotSd.- MRef
Scalar from
computeSldscMRef.- targetCategories
Character vector or NULL. If NULL, intersects the run's `categories` with `names(sdAnnot)`.
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")))
}
sd <- SldscData(annot = annot, frq = frq,
traits = setNames(list(mkTrait(), mkTrait()), c("traitX", "traitY")))
sdAnnot <- computeSldscAnnotSd(sd)
MRef <- computeSldscMRef(sd)
standardizeSldscTrait(sd, "traitX", mode = "single", idx = 1,
sdAnnot = sdAnnot, MRef = MRef, targetCategories = "annot_A_0")
#> Warning: standardizeSldscTrait: zero/NA sd for some targets; tau* will be NA/0.
#> $summary
#> # A tibble: 1 × 10
#> target tau tauSe tauStar tauStarSe enrichment enrichmentSe enrichmentP
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 annot_A_0 1e-7 3e-8 NA NA 2 0.4 0.01
#> # ℹ 2 more variables: enrichstat <dbl>, enrichstatSe <dbl>
#>
#> $tau_star_blocks
#> annot_A_0
#> [1,] NA
#> [2,] NA
#> [3,] NA
#> [4,] NA
#> [5,] NA
#> [6,] NA
#> [7,] NA
#> [8,] NA
#> [9,] NA
#> [10,] NA
#>
#> $h2g
#> [1] 0.3
#>
#> $nBlocks
#> [1] 10
#>
#> $mode
#> [1] "single"
#>