Skip to content

About

Preprocess and calculate polygenic risk scores of traits using pgsc_calc

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PRS Pipeline

A modular Python pipeline for Polygenic Risk Score (PRS) calculation using pgsc_calc, with statistical validation and clean score export.


Pipeline Overview

Step 1: Preprocessing    → detect input files, auto-generate samplesheet
Step 2: Run pgsc_calc    → run Nextflow + pgsc_calc
Step 3: Validate         → AUC, R², Odds Ratios, Cohen's d, plots
Step 4: Export Scores    → clean CSV/XLSX table ready to join to any metadata

Prerequisites

1. Python dependencies

pip install -r requirements.txt

2. Nextflow

# Requires Java 11+
curl -s https://get.nextflow.io | bash
mv nextflow ~/bin/   # or any directory on your PATH

Full instructions: https://www.nextflow.io/docs/latest/install.html

3. pgsc_calc

pgsc_calc runs via Nextflow and does not require a separate installation. It will be pulled automatically the first time you run Step 2.

Supported execution profiles (set in config.yaml):

  • conda — recommended for HPC/local use
  • docker — requires Docker daemon
  • singularity — recommended for clusters without Docker

Full pgsc_calc documentation: https://pgsc-calc.readthedocs.io


Setup

git clone https://github.com/jordanlab/PRS.git
cd PRS
pip install -r requirements.txt

Edit config.yaml with your paths before running any step.


Configuration (config.yaml)

# Path prefix to genotype files (glob-style, e.g. /path/to/ukb22418_c*_b0_v2)
genotype_prefix: "/path/to/your/genotypes/prefix"

# Where to write the auto-generated samplesheet
samplesheet_output: "/path/to/samplesheet.csv"

# pgsc_calc settings
output_dir:    "/path/to/pgsc_results/"
target_build:  "GRCh37"   # or GRCh38
profile:       "conda"    # docker, conda, or singularity

# Validation settings (Step 3)
data_file:      "/path/to/merged_prs_phenotype.csv"
val_output_dir: "/path/to/val_output/"

# Score export settings (Step 4)
scores_file:    ""   # leave blank to auto-detect from output_dir
export_output:  "/path/to/prs_scores_export.xlsx"

Usage

Run each step individually:

python main.py --step preprocess
python main.py --step run_pgsc_calc
python main.py --step validate
python main.py --step export_scores

To use a different config file:

python main.py --step preprocess --config /path/to/my_config.yaml

Step-by-Step Guide

Step 1 — Preprocessing

Detects your genotype files and auto-generates a pgsc_calc samplesheet.

Supports:

  • PLINK 1 binary (bfile: .bed/.bim/.fam)
  • PLINK 2 binary (pfile: .pgen/.pvar/.psam)
  • VCF / VCF.gz

Handles both:

  • Per-chromosome files (e.g. ukb22418_c1_b0_v2, ukb22418_c2_b0_v2 …)
  • Single merged files

After auto-generation, you will be prompted to review the samplesheet in your terminal editor before proceeding.


Step 2 — Run pgsc_calc

Builds and runs the Nextflow command. You will be prompted for:

  • PGS Catalog ID (e.g. PGS000039) — pgsc_calc downloads the scoring file automatically
  • Samplesheet path (from Step 1)
  • Optional flags: --min_overlap, --ancestry_method, --ref, --liftover, --keep_ambiguous

The full command is printed for your review before execution.

pgsc_calc output will be in output_dir as set in config.yaml. Key files:

  • score/*/aggregated_scores.txt.gz — PRS scores per sample
  • HTML report — interactive QC report

Step 3 — Validation

Requires a merged file with PRS scores, case/control status, and covariates (age, sex, PCs, etc.). You will be prompted to identify the relevant columns.

Outputs:

  • validation_summary.csv — AUC, incremental R², Cohen's d, t-test p-value
  • odds_ratios.csv — OR with 95% CI for all model terms
  • roc_curve.png
  • risk_gradient.png — case prevalence per PRS decile
  • prs_distribution.png — overlapping PRS density for cases vs controls

Step 4 — Export Scores

Parses aggregated_scores.txt.gz from pgsc_calc and exports a clean, joinable table.

Output: prs_scores_export.csv and prs_scores_export.xlsx

Columns: Patient_ID, PRS (or per-ancestry score columns if multiple are present).

To merge with your own patient metadata:

import pandas as pd

meta   = pd.read_excel("patient_metadata.xlsx")
prs    = pd.read_csv("prs_scores_export.csv")
merged = meta.merge(prs, on="Patient_ID", how="left")
merged.to_excel("patient_metadata_with_PRS.xlsx", index=False)

Input Format Notes

pgsc_calc Samplesheet

Auto-generated by Step 1. Format follows the pgsc_calc samplesheet specification.

Column Description
sampleset Name for your cohort
vcf_path Absolute path to VCF/VCF.gz (if applicable)
bfile_path Prefix for PLINK bfile (if applicable)
pfile_path Prefix for PLINK pfile (if applicable)
chrom Chromosome number (leave blank for merged files)
format vcf, bfile, or pfile

Maintained by

Valli Sree Lasya Pasumarthy
MS Bioinformatics, Jordan Lab
Georgia Institute of Technology

About

Preprocess and calculate polygenic risk scores of traits using pgsc_calc

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages