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
| Argument | Description |
|---|---|
gwas | Named 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. |
metadata | Data 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:
- a per-variant
n_effcolumn; ncaseandncontrolinmetadata-- their presence identifies a binary trait, so this is the reliable way to supply it;n_effinmetadata;- a per-variant
ncolumn, taken as a total (warns); sample_sizeinmetadata, 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
LoadLocalGWASRule, ExecutionEngine
Other generate-sources:
generate-gwascatalog,
generate-opengwas,
generate-sources