Skip to contents

Return a per-tuple summary-statistics data.frame in the standardized layout variant_id, chrom, pos, A1, A2, z, beta, se, N, maf (optional columns omitted when absent on the entry). Combines tuple-keyed row selection (getSumStats) with mcols unpacking; replaces the pre-S4 idiom of pulling S4Vectors::mcols(entry)$<col> directly inside pipelines.

Usage

getSumstatDf(x, ...)

# S4 method for class 'QtlSumStats'
getSumstatDf(
  x,
  study = NULL,
  context = NULL,
  trait = NULL,
  require = character(0),
  derive = c("none", "zFromBetaSe"),
  keepChrPrefix = TRUE
)

# S4 method for class 'GwasSumStats'
getSumstatDf(
  x,
  study = NULL,
  require = character(0),
  derive = c("none", "zFromBetaSe"),
  keepChrPrefix = TRUE
)

Arguments

x

A GwasSumStats or QtlSumStats object.

...

Class-specific selectors (study for GwasSumStats; study, context, trait for QtlSumStats) plus pass-throughs require, derive, keepChrPrefix forwarded to the underlying unpacker.

study

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

context

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

trait

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

require

Character vector. Columns that must be present (derived if necessary) in the returned summary-statistics data frame.

derive

Logical. Whether to derive missing standard columns (e.g. Z, BETA, SE) from the available ones.

keepChrPrefix

Logical. If TRUE, keep the chr prefix on chromosome names; otherwise strip it.

Value

A data.frame.

Examples

data(qtlSumStatsExample)
getSumstatDf(qtlSumStatsExample)
#> # A tibble: 200 × 10
#>    variant_id         chrom    pos A1    A2         z    beta    se     N    maf
#>    <chr>              <chr>  <int> <chr> <chr>  <dbl>   <dbl> <dbl> <dbl>  <dbl>
#>  1 chr22:14560203:A:G chr22 1.46e7 G     A     -1.02  -0.237  0.232   165 0.0758
#>  2 chr22:14564328:T:C chr22 1.46e7 C     T      0.109  0.0190 0.175   165 0.176 
#>  3 chr22:14850625:T:G chr22 1.49e7 G     T     -0.225 -0.0431 0.192   165 0.127 
#>  4 chr22:14870204:T:C chr22 1.49e7 C     T     -0.989 -0.119  0.121   165 0.352 
#>  5 chr22:14878387:G:A chr22 1.49e7 A     G     -0.884 -0.149  0.169   165 0.166 
#>  6 chr22:14880040:A:G chr22 1.49e7 G     A     -1.36  -0.191  0.140   165 0.179 
#>  7 chr22:14884399:T:C chr22 1.49e7 C     T      0.261  0.0429 0.164   165 0.136 
#>  8 chr22:15063831:A:G chr22 1.51e7 G     A     -0.895 -0.158  0.177   165 0.112 
#>  9 chr22:15257135:C:G chr22 1.53e7 G     C     -0.352 -0.0809 0.230   165 0.0710
#> 10 chr22:15266873:A:G chr22 1.53e7 G     A      0.602  0.0821 0.136   165 0.272 
#> # ℹ 190 more rows