Storage format internals

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.

1.76×
smaller than source (eQTLGen, ragged)
8.9ms
top-hit query, 121.9M associations
2arrays
canonical statistics stored (z, se)
7.1×
smaller than raw VCF at 1,000 analyses
01

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.

GWAS-VCF recordper variant · per analysis
  • 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
BESD triple.esi + .epi + .besd
  • .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]
02

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

betasez / ez eaf / freqninfo rsidstudy type
→

Canonical pair, per cell

zse

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.

Everything else moves to a coarser grain, or drops entirely. EAF is Variant-scoped, filled only where a reference panel supplies it — not stored per association. Sample size is typically Analysis-scoped, one value for the whole column. INFO is optional and Absent by default. None of the three is required to reconstruct beta, SE, Z, or p-value — that's the boundary the format is drawn on. — ADR-0005
03

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.)

Dense

Shared variant × analysis matrix

e.g. UK Biobank GWAS batches — every analysis reports on ~the same variants
  • Address a cellz[row, col] — O(1)
  • Missing cellNaN, no extra storage
  • Costdivergent analyses waste NaN cells
Ragged

Per-analysis retained sequence

e.g. eQTL/pQTL — each analysis keeps a different cis window
  • Address a celloffsets[i]…offsets[i+1], binary search
  • Missing cellnot represented at all
  • Costno shared column alignment across analyses
04

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 — from the source
Imputed — inferred from the LD panel
Missing — not observed, imputation declined or out of scope

Observed-Only

sparse — only what the source reported

Reference-Completed

same axis, gaps filled where the quality gate passes
Every imputed cell carries provenance, not just a value. A 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).
05

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.

Variant axis
variants.tsv.gz + .tbi
Tabix-indexed table — chromosome:position range fetches, rsid aliasing
range query
O(log n) seek
Row offsets
variant_offsets.npy
BGZF byte offset per variant_index — jump straight to one row, no scan
random row
O(1) seek
ALID search index
variant_alid_bytes/rows.npy
mmap'd, sorted — binary search a variant by identity, ~zero process startup cost
by ALID
O(log n), ~0MB RSS
Top-hit index
top_hits/p_5e_08, p_5e_06, p_5e_04
Precomputed, threshold-parameterised — significance queries skip the full matrix
tophits
no scan
Imputed mask
data.zarr/imputed (Reference-Completed only)
Parallel uint8 array — drives Association Status and observed_only filtering inline
status lookup
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.

06

Storage

Same UK Biobank chr1 source, two scales: the compressed .vcf.gz files OpenGWASDB actually reads, weighed against the Dense store it writes.

Raw source VCF vs. OpenGWASDB store
chr1 · 762,080 variants · UK Biobank GWAS-VCF, bgzip-compressed
Raw source (.vcf.gz)
OpenGWASDB store
100 analyses100 files
Raw VCF
1,308.2 MB
OpenGWASDB
309.4 MB
4.2× smaller
1,000 analyses1,000 files
Raw VCF
12,632.9 MB
OpenGWASDB
1,773.7 MB
7.1× smaller
The margin widens with scale, not narrows: each raw VCF pays its own per-file header and variant-ID overhead in full, while OpenGWASDB's variant axis, tabix index, and ALID index are built once and amortised across every additional analysis column. A 10× increase in analyses grows the raw source 9.7× but the store only 5.7× — and build time 8.8×.
Show data table
ScaleFormSizeRatio
100 analysesRaw VCF (.vcf.gz)1,308.16 MB1.00×
100 analysesOpenGWASDB store309.44 MB4.23×
1,000 analysesRaw VCF (.vcf.gz)12,632.86 MB1.00×
1,000 analysesOpenGWASDB store1,773.73 MB7.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.

07

Query time

Five access patterns, benchmarked the same way on both systems: median of 10 repetitions after one warm-up call.

OpenGWASDB vs besdq · 100 analyses
each panel scaled to its own max — bar length isn't comparable across panels, only within one
OpenGWASDB
besdq zstd
regional
odb
besdq
3.2× slower
phewas
odb
besdq
2.0× slower
tophits
odb
besdq
2.1× slower
bulk
odb
besdq
1.7× slower
random_lookup
odb
besdq
4.2× slower
Show data table
PatternOpenGWASDBbesdq zstdRatioWhat it reads
regional16.01 ms4.99 ms3.21×1 Mb window, all analyses
phewas1.82 ms0.91 ms2.01×1 variant × all analyses
tophits1.44 ms0.69 ms2.10×p < 5×10⁻⁸ for 1 analysis
bulk854.4 ms490.5 ms1.74×all ~762K variants, 1 analysis
random_lookup126.3 ms30.4 ms4.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.

Absolute latency at 1,000 analyses
same chr1 dataset, 10× the columns — log scale, one order of magnitude per gridline
regional
129.8 ms
phewas
7.8 ms
tophits
8.9 ms
bulk
5,546.6 ms
random_lookup
649.6 ms
1 ms10 ms100 ms1,000 ms
Show data table
PatternMedianp95Result cells
regional129.84 ms163.09 ms1,488,379
phewas7.75 ms10.98 ms1,000
tophits8.90 ms11.59 ms182,843
bulk5,546.56 ms6,936.65 ms762,080
random_lookup649.58 ms768.15 ms587

source: opengwasdb_vcf_ukb_chr1_1000_benchmark.json — no besdq run exists at this scale for direct comparison.