From a VCF row to an 8.9 ms lookup
OpenGWASDB takes per-analysis summary statistics — GWAS-VCF or BESD — and reduces them to two canonical arrays, a choice of physical layout, and a stack of purpose-built indexes. This is that pipeline end to end, grounded in the actual eQTLGen and UK Biobank benchmark runs.
What comes in
Two source formats reach the same canonical shape. GWAS-VCF carries one analysis per file; BESD carries a whole matrix of analyses (probes) per file set.
- CHROM, POSgenomic coordinate, hg19 or hg38
- REF, ALTalleles, oriented to canonical ALID on read
- EZz-score, preferred when present
- ES, SEeffect + standard error, fallback for z
- ##SAMPLEStudyType header → stored effect scale
- .esi rowchr, snp_id, bp, a1, a2, freq — shared variant list
- .epi rowchr, probe_id, bp, gene, orientation — one per analysis
- .besdbinary column table: snp_index[], beta[f32], se[f32]
What gets kept
Every source field collapses into one canonical statistic pair, plus a small set of values that only need to be known once per analysis or once per variant — never once per cell.
Arrives as
Canonical pair, per cell
beta is never stored — it's recovered as z × se on read.
Scale-agnostic, and avoids the undefined beta/z case when z is exactly zero.
Where the cells live
Same z/se pair, two physical shapes — chosen by whether analyses share a variant axis or each keep their own retained set. (Illustrative grid below; real stores range from hundreds of thousands to tens of millions of variants.)
Shared variant × analysis matrix
- Address a cellz[row, col] — O(1)
- Missing cellNaN, no extra storage
- Costdivergent analyses waste NaN cells
Per-analysis retained sequence
- Address a celloffsets[i]…offsets[i+1], binary search
- Missing cellnot represented at all
- Costno shared column alignment across analyses
Filling in against a reference panel
An Observed-Only release holds exactly what the source reported. Reference Completion is a separate, later pass: LD-block elastic-net imputation fills variants the source never observed, and every cell keeps a status.
Observed-Only
Reference-Completed
completion_quality row records the Pearson r of the fit, n_imputed, and
n_missing at LD-block × Analysis granularity. For Dense stores specifically, n_missing
splits further: n_missing_off_panel (source-only variants with no LD
structure — never imputable, tracked once per Analysis) versus
n_missing_imputation_failed (reference-panel variants where the fit
didn't clear the quality gate).
What sits alongside z and se
None of these change what a query returns — each one exists purely to avoid a full scan for a specific access pattern.
O(log n) seek
O(1) seek
O(log n), ~0MB RSS
no scan
O(1), no join
besdq, by comparison, resolves identity through an in-memory dict — O(1) but ≈1.5 GB resident at 12M variants. The mmap'd index trades a constant factor for near-zero startup memory.
Storage
Same UK Biobank chr1 source, two scales: the compressed .vcf.gz files OpenGWASDB actually reads, weighed against the Dense store it writes.
Show data table
| Scale | Form | Size | Ratio |
|---|---|---|---|
| 100 analyses | Raw VCF (.vcf.gz) | 1,308.16 MB | 1.00× |
| 100 analyses | OpenGWASDB store | 309.44 MB | 4.23× |
| 1,000 analyses | Raw VCF (.vcf.gz) | 12,632.86 MB | 1.00× |
| 1,000 analyses | OpenGWASDB store | 1,773.73 MB | 7.12× |
source: du -sb on besdq/data/vcf-ukb{,-1000}/*.vcf.gz; storage.store_bytes in opengwasdb_vcf_ukb_chr1_benchmark.json / opengwasdb_vcf_ukb_chr1_1000_benchmark.json. Excludes .csi sidecar indexes on the VCF side (+0.8% at 100 analyses) — not required to read the source, so not counted as source size.
Query time
Five access patterns, benchmarked the same way on both systems: median of 10 repetitions after one warm-up call.
Show data table
| Pattern | OpenGWASDB | besdq zstd | Ratio | What it reads |
|---|---|---|---|---|
| regional | 16.01 ms | 4.99 ms | 3.21× | 1 Mb window, all analyses |
| phewas | 1.82 ms | 0.91 ms | 2.01× | 1 variant × all analyses |
| tophits | 1.44 ms | 0.69 ms | 2.10× | p < 5×10⁻⁸ for 1 analysis |
| bulk | 854.4 ms | 490.5 ms | 1.74× | all ~762K variants, 1 analysis |
| random_lookup | 126.3 ms | 30.4 ms | 4.15× | 100 variants × 10 analyses |
source: opengwasdb_vcf_ukb_chr1_benchmark.json — honest state: OpenGWASDB reads two arrays (z, se) against besdq's one, and returns a sparse dict rather than a dense array, which accounts for part of the gap.
Show data table
| Pattern | Median | p95 | Result cells |
|---|---|---|---|
| regional | 129.84 ms | 163.09 ms | 1,488,379 |
| phewas | 7.75 ms | 10.98 ms | 1,000 |
| tophits | 8.90 ms | 11.59 ms | 182,843 |
| bulk | 5,546.56 ms | 6,936.65 ms | 762,080 |
| random_lookup | 649.58 ms | 768.15 ms | 587 |
source: opengwasdb_vcf_ukb_chr1_1000_benchmark.json — no besdq run exists at this scale for direct comparison.