Last updated: 2020-06-17

Checks: 7 0

Knit directory: analysis_pipelines/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20200524) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 3667a4d. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/sldsc_pipeline.Rmd) and HTML (docs/sldsc_pipeline.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 3667a4d kevinlkx 2020-06-17 wflow_publish(“analysis/sldsc_pipeline.Rmd”)
html f7fc98f kevinlkx 2020-05-24 Build site.
Rmd 1e524bf kevinlkx 2020-05-24 wflow_publish(“analysis/sldsc_pipeline.Rmd”)
html d5cee1f kevinlkx 2020-05-24 Build site.
html 83ec764 kevinlkx 2020-05-24 Build site.
html 4b55a7b kevinlkx 2020-05-24 Build site.
Rmd 90c2d75 kevinlkx 2020-05-24 wflow_publish(“analysis/sldsc_pipeline.Rmd”)
html a7c0900 kevinlkx 2020-05-24 Build site.
Rmd 1f7cb93 kevinlkx 2020-05-24 wflow_publish(“analysis/sldsc_pipeline.Rmd”)
html 76a500e kevinlkx 2020-05-24 Build site.
Rmd d07ad1d kevinlkx 2020-05-24 wflow_publish(“analysis/sldsc_pipeline.Rmd”)

Install LD Score Regression (LDSC) software

Please see the detail instructions: LD Score Regression (LDSC) https://github.com/bulik/ldsc

Download ldsc software

git clone https://github.com/bulik/ldsc.git
cd ldsc

Create a conda environment with LDSC’s dependencies

You might need to update numpy (and other packages) to a newer version (e.g. set numpy==1.16 or newer version)

conda env create --file environment.yml

Activate the conda environment with LDSC’s dependencies

conda activate ldsc

Test installation

If these commands fail with an error, then something as gone wrong during the installation process.

cd ldsc

python ./ldsc.py -h
python ./munge_sumstats.py -h

ldsc Wiki

The wiki has tutorials on estimating LD Score, heritability, genetic correlation and the LD Score regression intercept and partitioned heritability.

Tutorials for partitioning heritability using S-LDSC (stratified LD score regression)

ldsc FAQ

Common issues are described in the FAQ

References

  • Partitioned heritability: Finucane, HK, et al. Partitioning heritability by functional annotation using genome-wide association summary statistics. Nature Genetics, 2015.

  • Stratified heritability using continuous annotation: Gazal, S, et al. Linkage disequilibrium–dependent architecture of human complex traits shows action of negative selection. Nature Genetics, 2017.

Example

You may try this example to run S-LDSC on example data provided by the authors

Download LDSC reference data

You may need to download some of the following datasets:

Most of the data can be downloaded from the Price lab LDSCORE website

Download the baseline model LD scores

  • Readme of different versions of baseline models

  • 1000G Phase3 baseline model v1.1

wget https://data.broadinstitute.org/alkesgroup/LDSCORE/1000G_Phase3_baseline_v1.1_ldscores.tgz
mkdir 1000G_Phase3_baseline_v1.1_ldscores
tar -xvzf 1000G_Phase3_baseline_v1.1_ldscores.tgz -C 1000G_Phase3_baseline_v1.1_ldscores
  • 1000G Phase3 baselineLD model v1.1
wget https://data.broadinstitute.org/alkesgroup/LDSCORE/1000G_Phase3_baselineLD_v1.1_ldscores.tgz
mkdir 1000G_Phase3_baselineLD_v1.1_ldscores
tar -xvzf 1000G_Phase3_baselineLD_v1.1_ldscores.tgz -C 1000G_Phase3_baselineLD_v1.1_ldscores
  • 1000G Phase3 baselineLD model v2.2
wget https://data.broadinstitute.org/alkesgroup/LDSCORE/1000G_Phase3_baselineLD_v2.2_ldscores.tgz
mkdir 1000G_Phase3_baselineLD_v2.2_ldscores
tar -xvzf 1000G_Phase3_baselineLD_v2.2_ldscores.tgz -C 1000G_Phase3_baselineLD_v2.2_ldscores

Download regression weights

# wget https://data.broadinstitute.org/alkesgroup/LDSCORE/weights_hm3_no_hla.tgz
# tar -xvzf weights_hm3_no_hla.tgz

# European of Phase 3 of 1000 Genomes
wget https://data.broadinstitute.org/alkesgroup/LDSCORE/1000G_Phase3_weights_hm3_no_MHC.tgz
tar -xvzf 1000G_Phase3_weights_hm3_no_MHC.tgz

Download allele frequencies (European of Phase 3 of 1000 Genomes)

wget https://data.broadinstitute.org/alkesgroup/LDSCORE/1000G_Phase3_frq.tgz
tar -xvzf 1000G_Phase3_frq.tgz

The authors recommend only keeping HapMap3 SNPs. You can download the HapMap3 related files:

Download 1000 genomes reference genotypes at HapMap3 loci

wget https://data.broadinstitute.org/alkesgroup/LDSCORE/1000G_Phase3_plinkfiles.tgz
tar -xvzf 1000G_Phase3_plinkfiles.tgz

Download HapMap3 SNPs

wget https://data.broadinstitute.org/alkesgroup/LDSCORE/hapmap3_snps.tgz
tar -xvzf hapmap3_snps.tgz

Download a concatenated list of HapMap3 SNPs

wget https://data.broadinstitute.org/alkesgroup/LDSCORE/w_hm3.snplist.bz2
bzip2 -d w_hm3.snplist.bz2

# Extract the list of HapMap 3 SNPs rsIDs
awk '{if ($1!="SNP") {print $1} }' w_hm3.snplist > listHM3.txt

Compute LD score from functional annotations

Compute LD scores for binary annotations

  • Step 1: prepare annotation in UCSC BED format
  • Step 2: compute LD scores using annotation BED files

  • Example scripts: thin-annot annotation format using make_annot.py

for chrom in {1..22}
do
  echo ${chrom}

  ## Step 1: Creating an annot file
  echo "Make ldsc-friendly annotation files for ${ANNOT}.bed"
  python make_annot.py \
  --bed-file ${ANNOT}.bed \
  --bimfile 1000G_EUR_Phase3_plink/1000G.EUR.QC.${chrom}.bim \
  --annot-file ${ANNOT}.${chrom}.annot.gz

  ## Step 2: Computing LD scores with an annot file
  echo "Computing LD scores with the annot file ${ANNOT}.${chrom}.annot.gz"
  python ldsc.py \
  --l2 \
  --bfile 1000G_EUR_Phase3_plink/1000G.EUR.QC.${chrom} \
  --print-snps listHM3.txt \
  --ld-wind-cm 1 \
  --annot ${ANNOT}.${chrom}.annot.gz \
  --thin-annot \
  --out ${ANNOT}.${chrom}
done

full annotation or thin-annot format using this R script

for chrom in {1..22}
do
  echo ${chrom}

  ## Step 1: Creating an annot file
  echo "Make ldsc-friendly annotation files for ${ANNOT}.bed"
  Rscript code/make_ldsc_binary_annot.R \
  ${ANNOT}.bed \
  1000G_EUR_Phase3_plink/1000G.EUR.QC.${chrom}.bim \
  ${ANNOT}.${chrom}.annot.gz "full-annot"

  ## Step 2: Computing LD scores with an annot file
  echo "Computing LD scores with the annot file ${ANNOT}.${chrom}.annot.gz"
  python ldsc.py \
  --l2 \
  --bfile 1000G_EUR_Phase3_plink/1000G.EUR.QC.${chrom} \
  --print-snps listHM3.txt \
  --ld-wind-cm 1 \
  --annot ${ANNOT}.${chrom}.annot.gz \
  --out ${ANNOT}.${chrom}
done

Compute LD scores for continuous annotations

  • Step 1: prepare annotation in UCSC BED format
  • Step 2: compute LD scores using annotation BED files

  • Example script (full annotation format using this R script )


for chrom in {1..22}
do
  echo ${chrom}

  ## Step 1: Creating an annot file (using make_ldsc_continuous_annot.R)
  echo "Make ldsc-friendly annotation files for ${ANNOT}.bed"
  Rscript code/make_ldsc_continuous_annot.R \
  ${ANNOT}.bed \
  1000G_EUR_Phase3_plink/1000G.EUR.QC.${chrom}.bim \
  ${ANNOT}.${chrom}.annot.gz "full-annot"

  ## Step 2: Computing LD scores with an annot file
  echo "Computing LD scores with the annot file ${ANNOT}.${chrom}.annot.gz"
  python ldsc.py \
  --l2 \
  --bfile 1000G_EUR_Phase3_plink/1000G.EUR.QC.${chrom} \
  --print-snps listHM3.txt \
  --ld-wind-cm 1 \
  --annot ${ANNOT}.${chrom}.annot.gz \
  --out ${ANNOT}.${chrom}

done

Partitioned heritability (binary annotation)

Prepare GWAS summary stats in LDSC .sumstats format

  • Convert GWAS summary stats to the LDSC .sumstats format using munge_sumstats.py
  • ldsc wiki “Summary-Statistics-File-Format”
  • Note: you may need to add an option --chunksize 500000 to munge_sumstats.py command

  • Some of the processed GWAS summary stats (.sumstats format) can be found on RCC: /project2/xinhe/kevinluo/GWAS/GWAS_summary_stats/GWAS_collection/ldsc_format/

Run ldsc on your GWAS summary statistics using baseline-LD model annotations and your new annotation

  • Compute the annotation conditional on baselineLD model: controlling for the annotation categories of the full baselineLD model, using a comma-separated list of annotation file prefixes with --ref-ld-chr
python ldsc.py \
--h2 ${TRAIT}.sumstats.gz \
--ref-ld-chr baselineLD.,${ANNOT}. \
--frqfile-chr 1000G_Phase3_frq/1000G.EUR.QC. \
--w-ld-chr 1000G_Phase3_weights_hm3_no_MHC/weights.hm3_noMHC. \
--overlap-annot --print-cov --print-coefficients --print-delete-vals \
--out ${TRAIT}_${ANNOT}_baselineLD
  • Joint model: you could include multiple annotations file prefixes to run multiple annotations jointly
python ldsc.py \
--h2 ${TRAIT}.sumstats.gz \
--ref-ld-chr baselineLD.,${ANNOT_1}.,${ANNOT_2}. \
--frqfile-chr 1000G_Phase3_frq/1000G.EUR.QC. \
--w-ld-chr 1000G_Phase3_weights_hm3_no_MHC/weights.hm3_noMHC. \
--overlap-annot --print-cov --print-coefficients --print-delete-vals \
--out ${TRAIT}_joint_baselineLD

Partitioned heritability (continuous annotation)

  • ldsc allows taking continuous annotations as inputs for both –l2 and –h2 options. The pipeline is similar to that using binary annotation. However, some result outputs of –h2 option are not meaningful anymore. Computing the proportion of heritability explained by each quantile of a continuous annotation provides a more intuitive interpretation of the magnitude of a continuous annotation effects. You can use their R script quantile_h2g.r and follow their wiki tutorial to compute the proportion of heritability explained by each quintile.

  • Please follow the ldsc wiki “Partitioned Heritability from Continuous Annotations”


sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Scientific Linux 7.4 (Nitrogen)

Matrix products: default
BLAS/LAPACK: /software/openblas-0.2.19-el7-x86_64/lib/libopenblas_haswellp-r0.2.19.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] workflowr_1.6.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4.6    rprojroot_1.3-2 digest_0.6.25   later_1.0.0    
 [5] R6_2.4.1        backports_1.1.7 git2r_0.27.1    magrittr_1.5   
 [9] evaluate_0.14   stringi_1.4.6   rlang_0.4.6     fs_1.3.1       
[13] promises_1.1.0  whisker_0.4     rmarkdown_2.1   tools_3.5.1    
[17] stringr_1.4.0   glue_1.4.1      httpuv_1.5.3.1  xfun_0.14      
[21] yaml_2.2.0      compiler_3.5.1  htmltools_0.4.0 knitr_1.28