Last updated: 2020-07-08

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 2588e9d. 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/

Unstaged changes:
    Modified:   analysis/index.Rmd
    Modified:   analysis/sldsc_example_GTEx_QTLs.Rmd

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_example_neuron_ATACseq.Rmd) and HTML (docs/sldsc_example_neuron_ATACseq.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 2588e9d kevinlkx 2020-07-08 wflow_publish(“analysis/sldsc_example_neuron_ATACseq.Rmd”)
html 1ba32ea kevinlkx 2020-07-08 Build site.
Rmd 97bc801 kevinlkx 2020-07-08 wflow_publish(“analysis/sldsc_example_neuron_ATACseq.Rmd”)

Prepare annotation files and compute LD scores for annotations

Prepare annotations in BED format for ASoC binary annotations

  • Convert ASoC binary annotations to BED format. The annotations can be found in /project2/xinhe/kevinluo/ldsc/annot/annot_bed/
  • Annotations for ATAC-seq peaks in BED format can also be found in /project2/xinhe/kevinluo/ldsc/annot/annot_bed/.
## Prepare ASoC binary annotations in BED format for LDSC analysis
dir_annot_bed <- "/project2/xinhe/kevinluo/ldsc/annot/annot_bed/"

### ASoC_glut_anno_hg19
annot_name <- "ASoC_glut_anno_hg19"
annot_filename <- "ASoC_glut_anno_hg19.txt"
ASoC_annot <- read.table(paste0(dir_annot_bed, "/", annot_filename), header = F, stringsAsFactors = F)
colnames(ASoC_annot) <- c("chr", "SNP_POS", "annot")

ASoC_sig <- ASoC_annot[ASoC_annot$annot == 1, ]
ASoC_sig.bed <- data.frame(chr = ASoC_sig$chr, start = ASoC_sig$SNP_POS - 1, end = ASoC_sig$SNP_POS)
ASoC_sig.bed$chr <- factor(ASoC_sig.bed$chr, levels = paste0("chr", 1:22))
ASoC_sig.bed <- ASoC_sig.bed[order(ASoC_sig.bed$chr, ASoC_sig.bed$start), ]
ASoC_sig.bed <- unique(ASoC_sig.bed)
cat(nrow(ASoC_sig.bed), "SNPs with annotation:", annot_name, "\n")
write.table(ASoC_sig.bed, paste0(dir_annot_bed, "/", annot_name, ".bed"), sep = "\t", col.names = F, row.names = F, quote = F)

### ASoC_npc_anno_hg19
annot_name <- "ASoC_npc_anno_hg19"
annot_filename <- "ASoC_npc_anno_hg19.txt"
ASoC_annot <- read.table(paste0(dir_annot_bed, "/", annot_filename), header = F, stringsAsFactors = F)
colnames(ASoC_annot) <- c("chr", "SNP_POS", "annot")

ASoC_sig <- ASoC_annot[ASoC_annot$annot == 1, ]
ASoC_sig.bed <- data.frame(chr = ASoC_sig$chr, start = ASoC_sig$SNP_POS - 1, end = ASoC_sig$SNP_POS)
ASoC_sig.bed$chr <- factor(ASoC_sig.bed$chr, levels = paste0("chr", 1:22))
ASoC_sig.bed <- ASoC_sig.bed[order(ASoC_sig.bed$chr, ASoC_sig.bed$start), ]
ASoC_sig.bed <- unique(ASoC_sig.bed)
cat(nrow(ASoC_sig.bed), "SNPs with annotation:", annot_name, "\n")
write.table(ASoC_sig.bed, paste0(dir_annot_bed, "/", annot_name, ".bed"), sep = "\t", col.names = F, row.names = F, quote = F)

Compute LD scores for ATAC-seq peaks and ASoC annotations

The following code generates ldsc-friendly annotation files (annot.gz) from the annotation BED files, then computes LD scores with the annot file (annot.gz).

## Compute LD scores for ATAC-seq peak annotations
dir_code=~/projects/analysis_pipelines/code/

sbatch ${dir_code}/ldsc_binary_annot_QTL.sbatch CN_all_peaks.narrowPeak.cleaned.hg19.merged

sbatch ${dir_code}/ldsc_binary_annot_QTL.sbatch DN_all_peaks.narrowPeak.cleaned.hg19.merged

sbatch ${dir_code}/ldsc_binary_annot_QTL.sbatch GA_all_peaks.narrowPeak.cleaned.hg19.merged

sbatch ${dir_code}/ldsc_binary_annot_QTL.sbatch ips_all_peaks.narrowPeak.cleaned.hg19.merged

sbatch ${dir_code}/ldsc_binary_annot_QTL.sbatch NSC_all_peaks.narrowPeak.cleaned.hg19.merged

sbatch ${dir_code}/ldsc_binary_annot_QTL.sbatch NSC_all_peaks.narrowPeak.cleaned.hg19.merged

## Compute LD scores for ASoC annotations
sbatch ${dir_code}/ldsc_binary_annot_QTL.sbatch ASoC_glut_anno_hg19

sbatch ${dir_code}/ldsc_binary_annot_QTL.sbatch ASoC_npc_anno_hg19

Computed LD scores for ATAC-seq peaks and ASoC annotations can be found in /project2/xinhe/kevinluo/ldsc/annot/ldscores/.

Partition heritability using S-LDSC

https://github.com/bulik/ldsc/wiki/Partitioned-Heritability

Prepare GWAS summary stats in LDSC format

Convert GWAS summary stats to the .sumstats format using munge_sumstats.py

See this page for details

Partition heritability

The following code estimates the partitioned heritability and enrichment for annotations

#!/bin/bash

#SBATCH --job-name=sldsc
#SBATCH --output=sldsc_%J.out
#SBATCH --error=sldsc_%J.err
#SBATCH --partition=broadwl
#SBATCH --mem=10G

dir_GWAS=$1
trait=$2
prefix_annot=$3
dir_sLDSC_output=$4

dir_LDSC=/project2/xinhe/kevinluo/ldsc
dir_ldsc_annot=/project2/xinhe/kevinluo/ldsc/annot/ldscores
dir_baselineLD=/project2/xinhe/kevinluo/ldsc/LDSCORE/1000G_Phase3_baselineLD_v1.1_ldscores

conda activate ldsc

echo "GWAS trait: ${trait}"

dir_out=${dir_sLDSC_output}/${trait}/baselineLDv1.1
mkdir -p ${dir_out}

python $HOME/softwares/ldsc/ldsc.py \
--h2 ${dir_GWAS}/${trait}.sumstats.gz \
--ref-ld-chr ${dir_baselineLD}/baselineLD.,${dir_ldsc_annot}/${prefix_annot}/${prefix_annot}. \
--frqfile-chr ${dir_LDSC}/LDSCORE/1000G_Phase3_frq/1000G.EUR.QC. \
--w-ld-chr ${dir_LDSC}/LDSCORE/1000G_Phase3_weights_hm3_no_MHC/weights.hm3_noMHC. \
--overlap-annot --print-cov --print-coefficients --print-delete-vals \
--out ${dir_out}/${trait}_${prefix_annot}_baselineLDv1.1

Run S-LDSC across a number of GWAS traits over the ATAC-seq peaks and ASoC annotations.

Results are saved in /project2/xinhe/kevinluo/ldsc/results/sLDSC_neuron_ATACseq_examples/


TRAITS=("ADHD" "IBD" "BMI" "height" "SCZ" "BIP" "MDD" "iPSYCH_ASD" "Intelligence" "Education" "Neuroticism" "Alzheimer" "Parkinson")
dir_GWAS=/project2/xinhe/kevinluo/GWAS/GWAS_summary_stats/GWAS_from_Min/ldsc_format/
dir_sLDSC_output=/project2/xinhe/kevinluo/ldsc/results/sLDSC_neuron_ATACseq_examples/
dir_code=~/projects/analysis_pipelines/code/

for trait in "${TRAITS[@]}"
do
  sbatch ${dir_code}/sldsc_annot_baselineLD_separate.sbatch ${dir_GWAS} ${trait} CN_all_peaks.narrowPeak.cleaned.hg19.merged ${dir_sLDSC_output}

  sbatch ${dir_code}/sldsc_annot_baselineLD_separate.sbatch ${dir_GWAS} ${trait} DN_all_peaks.narrowPeak.cleaned.hg19.merged ${dir_sLDSC_output}

  sbatch ${dir_code}/sldsc_annot_baselineLD_separate.sbatch ${dir_GWAS} ${trait} GA_all_peaks.narrowPeak.cleaned.hg19.merged ${dir_sLDSC_output}

  sbatch ${dir_code}/sldsc_annot_baselineLD_separate.sbatch ${dir_GWAS} ${trait} ips_all_peaks.narrowPeak.cleaned.hg19.merged ${dir_sLDSC_output}

  sbatch ${dir_code}/sldsc_annot_baselineLD_separate.sbatch ${dir_GWAS} ${trait} NSC_all_peaks.narrowPeak.cleaned.hg19.merged ${dir_sLDSC_output}

  sbatch ${dir_code}/sldsc_annot_baselineLD_separate.sbatch ${dir_GWAS} ${trait} ASoC_glut_anno_hg19 ${dir_sLDSC_output}

  sbatch ${dir_code}/sldsc_annot_baselineLD_separate.sbatch ${dir_GWAS} ${trait} ASoC_npc_anno_hg19 ${dir_sLDSC_output}
done

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