This repository contains a set of Python scripts to:
- prepare and filter VCF files by chromosome;
- harmonize summary statistics with VCF variants;
- run PRSice for one or more ancestries;
- standardize PRS scores;
- run logistic regression and generate ROC curves.
The main workflow is:
- prepare the configuration file;
- process the VCFs by chromosome;
- merge the harmonized files and sumstats by ancestry using merge_harmonized.py;
- run PRSice;
- standardize the PRS scores;
- run the regression with multiple PRS.
In the project directory, run:
conda env create -f environment.yml
conda activate prs_envIf needed, also install manually:
pip install pandas pysam matplotlib scikit-learn statsmodels scipyEdit the main configuration file:
config.ini
Example structure:
[Project]
PROJECT_NAME = Epigen
[Paths]
PRSICE = /path/to/PRSice_linux
VCF_FILE = /path/to/VCF/file_chr@.vcf.gz
MSP_FILE = /path/to/file_chr@.msp
SUMSTATS_FILE_ANCESTRY = /path/to/sumstats1.txt:AFR,/path/to/sumstats2.txt:EUR
OUTPUT_DIR = /path/to/Results
[PRS]
LD_POP = LD_POP = /path/to_LD_file/afr_all:AFR,/path/to_LD_file/eur_all:EUR
PHENO_FILE = /path/to/phenfile.tsv
BINARY_TARGET = T
COVARIATE_FILE = None
COVARIATE_TO_INCLUDE = None
PRS_MISSING = SET_ZERO
SCORE_PRS = sum- The
LD_POPfield can beNoneif there are no LD reference files. - The phenotype file must have at least the following columns:
FIDIIDstatus
- The
statusvalue must be0or1. - If there are no covariates, keep:
COVARIATE_FILE = NoneCOVARIATE_TO_INCLUDE = None
Responsible for:
- splitting the VCF by chromosome;
- generating VCFs by ancestry;
- filtering variants against the sumstats;
Example execution:
python orquestrador.py --chroms 1 3 21 22or
python orquestrador.py --chrom-range 1 22Responsible for:
- locating all harmonized VCFs by ancestry;
- concatenating the VCFs into a single file per ancestry;
- combining the filtered sumstats into a single consolidated file;
- generating the
.bed/.bim/.famfiles required for PRSice.
Example execution:
python merge_harmonized.pyRuns PRSice for each ancestry defined in SUMSTATS_FILE_ANCESTRY.
Example:
python prs_run.pyStandardizes the PRS scores generated by PRSice and creates a file with the extension:
*.best.standardized
Example:
python standardize_prs.pyCombines the PRS from different ancestries and performs:
- logistic regression;
- AUC calculation;
- ROC curve generation;
- combined score distribution plots.
Example:
python regression_multi_prs.pyResults are saved in folders inside Results/, for example:
Results/
AFR/
EUR/
combined/
Typical generated files:
*_PRS_run.best*_PRS_run.best.standardized*_PRS_run.summary*_PRS_total_roc_curve.png*_PRS_total_distribuicao_prs.png*_comparacao_estatistica_*.txt
conda activate prs_env
python orquestrador.py --chrom-range 1 22
python merge_harmonized.py
python prs_run.py
python standardize_prs.py
python regression_multi_prs.py