PolyGenius
Contents

generate$sources$local

Local GWAS source

Declares in-memory or on-disk GWAS summary statistics as sources for generate$models(). Each entry of gwas becomes one gwas.sumstats resource, materialised during execution.

Usage

generate$sources$local(gwas, metadata)

Arguments

ArgumentDescription
gwasNamed list of data frames, or of functions of no arguments returning one. Each table needs chr, position, ea, nea, beta and pval; add se for LDpred2, lassosum2 or PRS-CS, which all require it even though no source rule does. Every entry must be named, and a data frame travels on the specification metadata, so a function entry keeps a large table out of memory until its rule runs.
metadataData frame with at least id and build, one row per entry in gwas; its id values must match names(gwas) exactly. Every extra column is carried into model$gwas verbatim, which is how sample sizes are supplied.

Value

A ResourceSpecSet of unresolved gwas.sumstats specifications, one per entry in gwas, for generate$models(sources = ).

Sample size -- total versus effective

LDpred2, lassosum2 and PRS-CS all need the effective sample size, because it sets the variance of each effect estimate. For a quantitative trait that equals the total; for a case/control trait it is 4 \cdot n_{case} \cdot n_{control} / (n_{case} + n_{control}). Supplying a total where an effective size is wanted rescales every weight, and no test on the data can detect it.

PolyGenius resolves it in this order, and only the last two warn:

  1. a per-variant n_eff column;
  2. ncase and ncontrol in metadata -- their presence identifies a binary trait, so this is the reliable way to supply it;
  3. n_eff in metadata;
  4. a per-variant n column, taken as a total (warns);
  5. sample_size in metadata, taken as a total (warns).

So for a case/control GWAS, give ncase and ncontrol. Passing only sample_size is the case that warns and, if the trait is binary, is wrong.

Examples

sumstats <- data.frame(
  chr = "1", position = 100000L, ea = "A", nea = "G",
  beta = 0.02, se = 0.004, pval = 1e-9
)
sources <- generate$sources$local(
  gwas     = list(my.gwas = sumstats),
  metadata = data.frame(id = "my.gwas", build = "hg19", ncase = 5000, ncontrol = 20000)
)

See Also

Aliases: generate-local, generate.sources.local, generate$sources$local