Nextflow pipeline for global and regional genetic correlations using GWAS summary statistics
Supports LDSC for genome-wide correlations and LAVA for local (regional) genetic correlations. The users can also follow-up the significant LAVA loci with Bayesian colocalization with coloc, to assess if there is a single shared causal variant.
Take a look at the workflow diagram for a visual overview.
This pipeline processes harmonized GWAS summary statistics (restricted to European ancestry for now) and computes:
- Global genetic correlations using LDSC (also computes SNP-based heritability)
- Local genetic correlations using LAVA (computes univariate and bivariate tests)
- Bayesian colocalization (optional; if enabled by user) using coloc (optional; across loci with significant regional genetic correlations)
There are several advantages of using the pipeline:
- Given that it uses an LDSC .sif image, there is no need to load old python versions (< v3) to run LDSC.
- The pipeline formats and adapts the GWAS summary statistics for each tool.
- The user does not need to prepare additional files, other than a metadata file.
- It partitions LAVA loci so that they all run in parallel, which significantly reduces the running time.
- It is reproducible and the user can easily re-run the analysis by adding/removing GWAS datasets from the metadata file.
git clone https://github.com/ape4fld/nf-genetic-correlations.git
cd nf-genetic-correlationsDownload the LDSC container image from Zenodo:
# Download the image (1.2GB)
wget https://zenodo.org/records/15920751/files/ldsc_latest.sif
# Place it in the bin/ directory
mv ldsc_latest.sif bin/Download the R container image from Zenodo:
# Download the image (420Mb)
wget https://zenodo.org/records/18683118/files/r_packages.sif
# Place it in the bin/ directory
mv r_packages.sif bin/-
Accepted formats:
.tsv,.csv,.txt, etc. -
Required columns (column names must match exactly, order can vary and other columns will be ignored):
variant_ideffect_alleleother_allelebetastandard_errorp_valueN
β οΈ variant_idmust be rsIDs. This pipeline is optimized for harmonized summary stats from the GWAS Catalog.
β οΈ If you plan to run colocalization analysis too, then you'll need two other columns in the GWAS summary statistics:chromosomeandbase_pair_location. Please make sure that all summary statistics are in genome build GRCh37 (for compatibility with LAVA loci).
- Create a directory for the summary statistics:
mkdir data/sumstats/
# Store the files here:
/nf-genetic-correlations/data/sumstats/Create a single file named metadata.txt, tab-separated, with the following columns:
| Column | Description |
|---|---|
dataset |
Short name for each dataset |
filename |
File name of the GWAS summary statistics file |
N |
Total sample size (use max if per-variant varies) |
cases |
Number of cases (use NA for continuous traits) |
controls |
Number of controls (use NA for continuous traits) |
- Store the metadata file in:
/nf-genetic-correlations/data/Note: an example of metadata.txt is included, which can be edited. Additionally, if the user wants to run the analysis across a subset of the GWAS datasets, it is possible to do so by creating a new metadata file including only those datasets (and specify the file name with the --metadata flag - see below 'π Running the Pipeline').
- LD Scores for LDSC
Download the LD scores from Zenodo:
# Download the compressed directory (65.9Mb)
wget -O eur_w_ld_chr.tar.gz https://zenodo.org/records/18749273/files/eur_w_ld_chr.tar.gz
# Uncompress the directory
tar -xf eur_w_ld_chr.tar.gzPlace /eur_w_ld_chr in ld_reference directory:
mv eur_w_ld_chr/ ./data/ld_reference/- 1000 Genomes Reference or UK Biobank reference (for LAVA) Download European PLINK reference files as described in the LAVA reference guide or download UK Biobank reference files as described in the LAVA reference guide. Note that LAVA developers highly recommend to use the UK Biobank reference file.
Place 1000 Genomes Reference contents in:
/nf-genetic-correlations/data/ld_reference/g1000_eur/Place UK Biobank reference contents in:
/nf-genetic-correlations/data/ld_reference/ukb_eur/Note: The default LD reference file that is used is the UK Biobank, but the user can specify the LD source with the --lava_ref flag (options: 1KGP_EUR or UKB) - see run_nextflow.sh).
The pipeline uses relative paths by default, making it portable across different systems. The configuration is set up for Digital Research Alliance Canada clusters but can be adapted for other environments.
- For Digital Research Alliance Canada users, update the SLURM account in the Nextflow config file:
process.clusterOptions = '--account=def-xxxxx' // Replace with your allocation- For other HPC/local systems, you may need to:
- Change the
executorfrom 'slurm' to your system (e.g., 'local', 'sge', 'pbs') - Adjust resource allocations (memory, CPUs, time)
The LAVA process is currently set to 1 hour, which works well for 4-5 phenotypes. However, running time increases with more datasets due to pairwise comparisons:
- 3 datasets = 3 pairs
- 5 datasets = 10 pairs
- 10 datasets = 45 pairs
To adjust the time limit, modify in the Nextflow config file:
withLabel: lava {
time = "1h" // Increase for larger analyses
}The pipeline expects this structure relative to where your main_full.nf file is located.
Once you've completed the setup and configuration, you can run the pipeline:
-
Edit the SLURM script run_nextflow.sh:
- Replace
def-xxxxxwith your compute allocation - Options in Nextflow command (see
run_nextflow.shfor an example). - All flags are optional.
Flag Description Default --run_id Give the specific run a prefix no prefix --metadata Provide a different name to the metadata file metadata.txt --lava-ref Specify LD reference for LAVA ('1KGP_EUR' or 'UKB') 'UKB' --coloc Include colocalization analysis (true or false) false --pvalue_LAVA_coloc Provide p-value cutoff for a significant local genetic correlation (for use with --coloc) 0.05 --clean_files_only Delete intermediate files generated, keep only final results true - Replace
-
Submit the job:
sbatch run_nextflow.sh
Run Nextflow directly:
nextflow run main_full.nf -profile <your_profile> -resume \
--run_id analysis1 \
--metadata ./data/metadata.txt \
--lava_ref 'UKB'The nf-genetic-correlations pipeline will:
- Process your GWAS summary statistics
- Calculate global genetic correlations using LDSC
- Calculate local genetic correlations using LAVA (the bivariate test is only performed for loci that passed a Bonferroni-corrected univariate test (i.e., pvalue < 0.05/2,945))
- Optionally perform colocalization analysis using coloc R package (performed for pairs of traits with significant local genetic correlations (significance defined by the user)
- Output results to the
results/directory
The pipeline generates results in the following directory structure:
results/
βββ formatted/ # Formatted summary statistics
β βββ formatted_*.tsv # One file per GWAS dataset (kept only if --clean_files_only = false)
βββ munged/ # LDSC-ready files
β βββ *.sumstats.gz # Munged summary statistics (kept only if --clean_files_only = false)
βββ ldsc_h2/ # Heritability estimates
β βββ *.h2_results # SNP-heritability for each trait
βββ ldsc_rg/ # Global genetic correlations
β βββ *.rg_results # Pairwise genetic correlations (kept only if --clean_files_only = false)
β βββ *_all_rg_results.tsv # Combined results table
βββ LAVA/ # Local genetic correlations
β βββ *univ.lava.tsv # Univariate test results (one line per trait)
β βββ *bivar.lava.tsv # Bivariate test results (one line per trait pair)
βββ coloc/ # Colocalization results, if enabled by user
βββ *_coloc_all.txt # Coloc results (one line per variant assessed across traits and loci)
βββ *_coloc_summary.txt # Coloc summary results (one line per locus)
data/LAVA/ # LAVA input files
βββ info_file.txt # Trait information
βββ sample_overlap.txt # Sample overlap matrix
Please open an issue if you have questions/suggestions about this Nextflow pipeline, if you encounter problems or if you find a bug! Remember to include your input and output for easier debugging; the more information the better.