Skip to contents

Get one trait's run from an SldscData

Usage

getTraitRun(x, trait, ...)

# S4 method for class 'SldscData'
getTraitRun(x, trait, mode = c("single", "joint"), idx = NULL)

Arguments

x

An SldscData object.

trait

Character. Trait name.

...

Further arguments: mode ("single"/"joint") and idx (which single run).

mode

Character. Trait-run selection mode.

idx

Integer. Index of the trait run to select.

Value

A single run list, the list of single runs, or NULL.

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)
getTraitRun(sd, "traitX")
#> [[1]]
#> [[1]]$categories
#> [1] "annot_A_0"    "baselineLD_0"
#> 
#> [[1]]$tau
#>    annot_A_0 baselineLD_0 
#>        1e-07        1e-07 
#> 
#> [[1]]$tauSe
#>    annot_A_0 baselineLD_0 
#>        3e-08        3e-08 
#> 
#> [[1]]$enrichment
#>    annot_A_0 baselineLD_0 
#>            2            2 
#> 
#> [[1]]$enrichmentSe
#>    annot_A_0 baselineLD_0 
#>          0.4          0.4 
#> 
#> [[1]]$enrichmentP
#>    annot_A_0 baselineLD_0 
#>         0.01         0.01 
#> 
#> [[1]]$propH2
#>    annot_A_0 baselineLD_0 
#>          0.2          0.2 
#> 
#> [[1]]$propSnps
#>    annot_A_0 baselineLD_0 
#>          0.1          0.1 
#> 
#> [[1]]$h2g
#> [1] 0.3
#> 
#> [[1]]$tauBlocks
#>       annot_A_0 baselineLD_0
#>  [1,]     1e-07        1e-07
#>  [2,]     1e-07        1e-07
#>  [3,]     1e-07        1e-07
#>  [4,]     1e-07        1e-07
#>  [5,]     1e-07        1e-07
#>  [6,]     1e-07        1e-07
#>  [7,]     1e-07        1e-07
#>  [8,]     1e-07        1e-07
#>  [9,]     1e-07        1e-07
#> [10,]     1e-07        1e-07
#> 
#> [[1]]$nBlocks
#> [1] 10
#> 
#> 
#> [[2]]
#> [[2]]$categories
#> [1] "annot_B_0"    "baselineLD_0"
#> 
#> [[2]]$tau
#>    annot_B_0 baselineLD_0 
#>        1e-07        1e-07 
#> 
#> [[2]]$tauSe
#>    annot_B_0 baselineLD_0 
#>        3e-08        3e-08 
#> 
#> [[2]]$enrichment
#>    annot_B_0 baselineLD_0 
#>            2            2 
#> 
#> [[2]]$enrichmentSe
#>    annot_B_0 baselineLD_0 
#>          0.4          0.4 
#> 
#> [[2]]$enrichmentP
#>    annot_B_0 baselineLD_0 
#>         0.01         0.01 
#> 
#> [[2]]$propH2
#>    annot_B_0 baselineLD_0 
#>          0.2          0.2 
#> 
#> [[2]]$propSnps
#>    annot_B_0 baselineLD_0 
#>          0.1          0.1 
#> 
#> [[2]]$h2g
#> [1] 0.3
#> 
#> [[2]]$tauBlocks
#>       annot_B_0 baselineLD_0
#>  [1,]     1e-07        1e-07
#>  [2,]     1e-07        1e-07
#>  [3,]     1e-07        1e-07
#>  [4,]     1e-07        1e-07
#>  [5,]     1e-07        1e-07
#>  [6,]     1e-07        1e-07
#>  [7,]     1e-07        1e-07
#>  [8,]     1e-07        1e-07
#>  [9,]     1e-07        1e-07
#> [10,]     1e-07        1e-07
#> 
#> [[2]]$nBlocks
#> [1] 10
#> 
#>