A modular Python pipeline for Polygenic Risk Score (PRS) calculation using pgsc_calc, with statistical validation and clean score export.
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
pip install -r requirements.txt# Requires Java 11+
curl -s https://get.nextflow.io | bash
mv nextflow ~/bin/ # or any directory on your PATHFull instructions: https://www.nextflow.io/docs/latest/install.html
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 usedocker— requires Docker daemonsingularity— recommended for clusters without Docker
Full pgsc_calc documentation: https://pgsc-calc.readthedocs.io
git clone https://github.com/jordanlab/PRS.git
cd PRS
pip install -r requirements.txtEdit config.yaml with your paths before running any step.
# 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"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_scoresTo use a different config file:
python main.py --step preprocess --config /path/to/my_config.yamlDetects 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.
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
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-valueodds_ratios.csv— OR with 95% CI for all model termsroc_curve.pngrisk_gradient.png— case prevalence per PRS decileprs_distribution.png— overlapping PRS density for cases vs controls
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)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 |
Valli Sree Lasya Pasumarthy
MS Bioinformatics, Jordan Lab
Georgia Institute of Technology