Skip to content

JuMa555/TwoSampleMR-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TwoSampleMR-Python

A package for performing Mendelian randomization using GWAS summary data. It allows causal inference using genetic variants as instrumental variables, fully integrated with the IEU OpenGWAS database.

This repository contains a reimplementation of the TwoSampleMR package.
It was developed as part of a master's thesis at UniZg-FER for academic purposes and learning.

PyPI version

Module Description
instruments.py Extracts instruments from OpenGWAS.
query.py Queries outcome data from OpenGWAS.
harmonise.py Harmonises exposure and outcome datasets.
mr.py Core MR methods (IVW, Egger, Median, Mode, GRIP).
heterogeneity.py Heterogeneity and pleiotropy tests.
multivariable_mr.py Multivariable MR framework.

Installation

pip install twosamplemr

Example Usage:

from twosamplemr.instruments import extract_instruments
from twosamplemr.query import extract_outcome_data
from twosamplemr.harmonise import harmonise_data
from twosamplemr.mr import mr

exposure = extract_instruments(["ieu-a-2"])
outcome = extract_outcome_data(exposure["SNP"], ["ieu-a-7"])
dat = harmonise_data(exposure, outcome)
res = mr(dat)
print(res)

This project is based on the original R implementation by Gibran Hemani, Philip Haycock, Jie Zheng, Tom Gaunt, Ben Elsworth, Tom Palmer, available at MRC IEU TwoSampleMR, licensed under the MIT License.

MIT License © 2025 Jurica Matosic

About

Python package for performing 2-sample MR using IEU OpenGWAS database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages