How bulik/ldsc works
Project type and purpose
• This is a Python-based command‐line tool (“ldsc”) for genetic analyses: computing LD Scores, estimating heritability (h2), performing partitioned h2 analyses, and genetic correlation from GWAS summary statistics.
• Key entrypoints: ldsc.py (LD Score regression), munge_sumstats.py (preprocessing), make_annot.py (annotation creation).
File structure
• Top-level scripts: ldsc.py, munge_sumstats.py, make_annot.py, test/simulate.py.
• Core library: directory ldscore/ with modules:
• parse.py – reading and validating input files
• ldscore.py – computing LD Scores
• sumstats.py – handling summary statistic files
• regressions.py – running regression engines
• jackknife.py, irwls.py – statistical backends
• Configuration: environment.yml, requirements.txt, setup.py.
• Test suite under test/ for unit and integration tests against known data.
Additional insights from README
• Relies on external data (1000 Genomes–based LD Scores).
• Four major workflows: LD-Score estimation, single‐trait h2, partitioned h2, genetic correlations.
• Uses Anaconda for dependency management.
Core components
a. Components
• CLI Layer:
• ldsc.py
• munge_sumstats.py
• make_annot.py
• Core Library (ldscore package):
• Input Parser (parse.py)
• Data Models (sumstats.py, annotations)
• Computation Engines (ldscore.py, regressions.py, jackknife.py, irwls.py)
• Data Sources:
• User GWAS summary stats
• Reference LD Score files (external downloads)
• Annotation files (ContinuousAnnotations, make_annot)
• Environment & Dependencies
• Outputs: heritability reports, LD Score files, genetic correlation matrices.
• Testing Framework: test/ directory with fixtures and test scripts.
b. Relationships & data flow
1. User invokes a CLI script (e.g., ./ldsc.py or ./munge_sumstats.py).
2. Script calls parse.py to ingest input files (sumstats/Munge).
3. Data Models (sumstats.py) normalize and validate data.
4. LD Score computation in ldscore.py (may call external reference files).
5. Regression engines (regressions.py) invoke statistical routines (jackknife, irwls).
6. Results written to disk.
7. Tests call library functions and compare outputs against test fixtures.
c. Architectural patterns & principles
• Modular CLI → Library separation: Top-level scripts delegate to ldscore package.
• Single Responsibility: each module (parse, ldscore, regressions, sumstats) has clear scope.
• Data‐pipeline style for workflows: sequential stages (parse → compute → regress → output).
• Test‐driven: extensive test suite validating each module.
d. Key technologies/frameworks
• Python 2/3 (Anaconda environment)
• NumPy/SciPy (statistical routines)
• pandas (possibly for table handling)
• External data: 1000 Genomes LD Score tarballs.