Two-sample Mendelian randomization implemented in Python
Project description
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.
| 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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file twosamplemr-0.1.3.tar.gz.
File metadata
- Download URL: twosamplemr-0.1.3.tar.gz
- Upload date:
- Size: 35.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d26100fb1310701028f2987a940f90bb5f78d0f92b1a4ff53e574f1f98caa6a
|
|
| MD5 |
b2ff7094f1d492a1605a5e4cedf073e1
|
|
| BLAKE2b-256 |
0d2f22011aa854d3013ff9b17c9bd45b51dc5d2b892578dbb15725980c8ff7aa
|
File details
Details for the file twosamplemr-0.1.3-py3-none-any.whl.
File metadata
- Download URL: twosamplemr-0.1.3-py3-none-any.whl
- Upload date:
- Size: 41.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de2ab58e11f655fd9ed4e1f15c4e43eaf654c231f9be71361d6be1c1042c89a4
|
|
| MD5 |
90997658da6d772e66e12e261658a4bd
|
|
| BLAKE2b-256 |
702635aaa21b2a9103380c26e7a5423216b93e732fc5dfc8b7983f13b1731c01
|