Skip to contents

Coerce one tuple of a GwasSumStats or QtlSumStats collection to a per-variant 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). This is the table view of sumStats, which returns the same selection as a GRanges; coercion rather than a return-type argument is the Bioconductor idiom for choosing a representation.

Usage

# S4 method for class 'QtlSumStats'
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  studyName = NULL,
  context = NULL,
  trait = NULL,
  require = character(0),
  derive = c("none", "zFromBetaSe"),
  keepChrPrefix = TRUE,
  ...
)

# S4 method for class 'GwasSumStats'
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  studyName = NULL,
  require = character(0),
  derive = c("none", "zFromBetaSe"),
  keepChrPrefix = TRUE,
  ...
)

Arguments

x

A GwasSumStats or QtlSumStats object.

row.names, optional

Accepted for compatibility with as.data.frame and ignored.

studyName

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 (QtlSumStats only).

trait

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

require

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

derive

Whether to derive missing standard columns from the available ones; "zFromBetaSe" recovers z from beta/se.

keepChrPrefix

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

...

Unused.

Value

A data.frame.

Examples

data(qtlSumStatsExample)
head(as.data.frame(qtlSumStatsExample))
#> # A tibble: 6 × 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