Skip to main content

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.

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 instruments import extract_instruments
from query import extract_outcome_data
from harmonise import harmonise_data
from 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)

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

twosamplemr-0.1.2.tar.gz (35.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

twosamplemr-0.1.2-py3-none-any.whl (41.3 kB view details)

Uploaded Python 3

File details

Details for the file twosamplemr-0.1.2.tar.gz.

File metadata

  • Download URL: twosamplemr-0.1.2.tar.gz
  • Upload date:
  • Size: 35.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for twosamplemr-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a0cd8fde76c06a157e381928a52377f7e2fe599ea6e2056cc6a61941c3a4295f
MD5 fa7fc06bb54c444de78a6409c9639230
BLAKE2b-256 efe6ee9408c09d8c317b2d53d96b53dded9a3b834b9448e9a4467bd90f10e239

See more details on using hashes here.

File details

Details for the file twosamplemr-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: twosamplemr-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 41.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for twosamplemr-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b8afffc87fe6a1cbdccaf2268f91d97ad6cb20b31542df63673da9e418ac5e3a
MD5 ffac2632c9de5b4edd21d5f8e5453fa0
BLAKE2b-256 5911fab84775dc1705eed2d8caef7d550b33dba4e33d601a565d6957610b21d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page