This repository contains:
-
LD scores for LDscore regression, as well as Nextflow pipelines and data to generate them, as described in the wiki of the original ldsc software.
-
A Dockerfile which will generate an image containing a newer version of the ldsc software plus the scores from this repository, which you can use to run LDscore regression yourself.
You need Docker
Clone this repository, enter it, and build the image (the docker tag below is given for example purposes):
git clone https://github.com/MRCIEU/ldsc
cd ldsc
docker build --platform linux/x86_64 --no-cache -t mrcieu/ldsc:ldsc-0448dd3-python3.13 .ldsc.py, munge_sumstats.py and make_annot.py are in the PATH so you can run, for example:
docker run mrcieu/ldsc:ldsc-0448dd3-python3.13 ldsc.py -h
or
docker run mrcieu/ldsc:ldsc-0448dd3-python3.13 munge_sumstats.py -h
To run ldsc for real, you can do something like:
docker run \
-w /work \
-v ${PWD}:/work \
mrcieu/ldsc:ldsc-0448dd3-python3.13 \
ldsc.py \
--h2 sumstats.gz \
--ref-ld-chr /ldscores/GRCh38/EUR/ \
--w-ld-chr /ldscores/GRCh38/EUR/ \
--out ldsc.h2
or
docker run \
-w /work \
-v ${PWD}:/work \
mrcieu/ldsc:ldsc-0448dd3-python3.13 \
ldsc.py \
--h2 sumstats.gz \
--ref-ld-chr /ldscores/GRCh37/WEIGHTED_MEAN_UKB/ \
--w-ld-chr /ldscores/GRCh37/WEIGHTED_MEAN_UKB/ \
--not-M-5-50 \
--out ldsc.h2
Where /ldscores/GRCh37/... is pointing to the LDscores from this repository (see below) which were copied into the container when the image was built. You can use your own scores by changing the paths.
A set of scores have been generated for each of the following 1000 Genomes super-populations:
1) AFR
2) AMR
3) EAS
4) EUR
5) SAS
Separate pipelines exist for both GRCh37 and GRCh38 human genome builds (which have slightly different input data).
The pipelines require that you download ~33GB (14GB) of 1000 Genomes data as input for GRCh38 (GRCh37). Scripts to download these data exist in this repository in GRCh3{X}/data/download_data.sh. Run these shell scripts before running the relevant nextflow pipeline.
88MB of precomputed information about ~1.2 million HapMap3 SNPs is already present in GRCh3{X}/data/hm3/, and is also required to run the pipeline. These data consist of the list of snps (labelled by RSID) (GRCh37/data/hm3/w_hm3.snplist), and per-chromosome tables linking snps (RSIDs) to their genomic location. These data were generated by the scripts GRCh3{X}/scripts/get_RSID_info.R.
Genetic map data is already present in GRCh3{X}/data/map/. For GRCh38 the map data (in GRCh38/data/hm3/map) was obtained, then derived, from Halldorsson et al. 2019. For GRCh37 the map data is from here.
The various software the pipelines need are available as docker images in dependencies/. If you build them, you can run:
cd GRCh3{X}
nextflow run main.nf
Optionally, you can set the sample size to (randomly) subset the populations to, prior to calculating LDscores, and specify the name of the directory to write the results to:
nextflow run main.nf --n 100 --results_dir output
If you don't set these options, their defaults are n=300 and results_dir=results
The (per-chromosome) LDscores are written to
{results_dir}/
ldscores/
AFR/
AMR/
EAS/
EUR/
SAS/
And the sample lists retained after subsetting the data to n individuals for each population are written to
{results_dir}/sample_lists/{POP}.samples.tsv
The R script make_weightedmean_ldscores.R will generate LD scores based on the mean values from AFR AMR EAS EUR and SAS populations (by default the scores in this repository, but you can provide scores for those populations yourself):
❯ ./make_weightedmean_ldscores.R -h
Usage: If using the scores from this repository, provide --build and sample sizes [--nafr, --namr, etc.]
for at least two populations.
Otherwise you can provide paths to any (AFR, AMR, EAS, EUR or SAS) scores using the --pX flags + your
desired sample sizes
Write mean LDscores for multiple ancestries, weighted by sample sizes
Options:
-h, --help
Show this help message and exit
--build=BUILD
Genome build: GRCh37 or GRCh38
--nafr=NAFR
Number of samples with AFR ancestry
--namr=NAMR
Number of samples with AMR ancestry
--neas=NEAS
Number of samples with EAS ancestry
--neur=NEUR
Number of samples with EUR ancestry
--nsas=NSAS
Number of samples with SAS ancestry
--pafr=PAFR
Path to LDscores for AFR ancestry
--pamr=PAMR
Path to LDscores for AMR ancestry
--peas=PEAS
Path to LDscores for EAS ancestry
--peur=PEUR
Path to LDscores for EUR ancestry
--psas=PSAS
Path to LDscores for SAS ancestry
--outdir=OUTDIR
name of output folder to write weighted mean ldscores to
Precomputed mean scores across all five ancestries are available with 1) no weighting by sample size (i.e. just the arithmetic mean), and 2) weighted according to the inferred genetic ancestries of participants in the UK Biobank, in the following directory structure:
GRCh3{X}/
results/
ldscores/
MEAN/
WEIGHTED_MEAN_UKB/
These scores were generated as follows (for GRCh38):
❯ ./make_weightedmean_ldscores.R --build GRCh38 --nafr 9358 --namr 1114 --neas 2831 --neur 465060 --nsas 10014 --outdir GRCh38/results/ldscores/WEIGHTED_MEAN_UKB
❯ ./make_weightedmean_ldscores.R --build GRCh38 --nafr 1 --namr 1 --neas 1 --neur 1 --nsas 1 --outdir GRCh38/results/ldscores/MEAN
The results for the mean LD scores only contain the {chr}.l2.M files, not the {chr}.l2.M_5_50 files, so to use them you will need to pass the --not-M-5-50 flag to ldsc.py.
Per chromosome plots of the scores are available in GRCh3{X}/scripts/plot_LDscores.html. The shaded area on chromosome 6 is roughly the extended HLA region. Tables of all populations' scores are also available in GRCh3{X}/results/ldscores.all.plusMean.tsv.gz.
Related samples (as defined in GRCh38/data/vcf/20130606_g1k_3202_samples_ped_population.txt and GRCh37/data/vcf/20140625_related_individuals.txt) are removed prior to choosing samples for inclusion in the LD calculations.