Skip to main content

LDlinkPy

A Python interface to LDlink for reproducible linkage disequilibrium workflows

Project status: First public release series. Feedback and issue reports are welcome.

MIT License Python 3.10+

Introduction

LDlink is an interactive suite of web-based tools for investigating linkage disequilibrium (LD) across ancestral population groups. LDlink uses publicly available 1000 Genomes Project reference haplotypes to calculate population-specific LD, accepts variants as RefSNP (RS) numbers or genomic positions, and references dbSNP for RS identifiers and bi-allelic variant information. Depending on the module, LDlink also incorporates data from resources such as UCSC RefSeq, RegulomeDB, genetic maps, the GTEx Portal, the GWAS Catalog, and FORGEdb.

Internet access and a personal LDlink API token are required for API calls.

Install

LDlinkPy is available from PyPI. Using a virtual environment is recommended.

Requirements

  • Python 3.10 or newer

macOS / Linux

python3 -m venv .venv
./.venv/bin/python -m pip install --upgrade pip
./.venv/bin/python -m pip install ldlinkpy

Windows PowerShell

py -m venv .venv
.\.venv\Scripts\python -m pip install --upgrade pip
.\.venv\Scripts\python -m pip install ldlinkpy

Quick Start

1. Get And Set Your LDlink Token

Request a personal access token at https://ldlink.nih.gov/apiaccess. Once registered, your token will be emailed to you.

LDlinkPy reads your token from the LDLINK_TOKEN environment variable by default. You can also pass token="your_token_here" directly to endpoint functions.

macOS / Linux:

export LDLINK_TOKEN="your_token_here"

Windows PowerShell:

$env:LDLINK_TOKEN="your_token_here"

2. Start Python

macOS / Linux:

./.venv/bin/python

Windows PowerShell:

.\.venv\Scripts\python

3. Import LDlinkPy

from ldlinkpy import list_pop, list_chips, ldpair, ldproxy

4. Try A Simple Lookup

List available 1000 Genomes populations:

list_pop()

Example output for list_pop()

List available genotyping SNP chips:

list_chips()

5. Run A Simple Analysis

Check LD between two variants:

ldpair("rs3", "rs4", pop="YRI")

Example output for ldpair()

Find proxy variants for a SNP:

ldproxy("rs7412", pop="CEU")

Public Functions

Function Purpose
ldpair Query LD statistics for one or more variant pairs.
ldmatrix Create an LD matrix for a set of variants.
ldproxy Find proxy variants for a query variant.
ldproxy_batch Run multiple LDproxy queries and write result files.
ldtrait Query trait associations linked to variants in LD.
ldexpress Query GTEx expression associations for variants in LD.
ldhap Query haplotype and variant tables for a variant set.
ldpop Query LD statistics across populations for two variants.
snpclip Prune variants by LD and minor allele frequency thresholds.
snpchip Identify genotyping arrays containing variants.
list_pop Return available 1000 Genomes population codes.
list_chips / list_chip_platforms Return available genotyping chip/platform codes.
list_gtex_tissues Return GTEx tissue names and LDexpress tissue codes.

Most endpoint functions return pandas DataFrames by default. Some functions support raw responses, file output, or endpoint-specific return shapes. See the API reference for details.

More Documentation

  • API reference: public functions, parameters, return types, and common exceptions.
  • Longer usage examples: endpoint-by-endpoint command-line examples for local development and exploratory testing.
  • End-to-end examples: includes an LDlinkPy-only workflow examining population-specific LD, haplotype structure, and optional SNPchip coverage for published SNP tags at the Ewing sarcoma 6p25.1/RREB1 susceptibility locus.

Authorship

LDlinkPy was conceived and overseen by Timothy Myers, Stephen Chanock, and Mitchel Machiela, with code and documentation assistance from ChatGPT 5.2 Thinking (OpenAI) and Codex 5.5 High (OpenAI). Additional authors and contributors may be added as the project develops.

AI Assistance Disclosure

LDlinkPy was developed with assistance from AI coding tools and agents, including ChatGPT 5.2 Thinking (OpenAI) and Codex 5.5 High (OpenAI). AI tools assisted with code generation, implementation, and documentation. Package behavior is validated by comparing outputs against the LDlink web app and the LDlinkR R package. Human contributors conceived the project, directed development, defined validation criteria, ran validation checks, and made release decisions.

Relationship To LDlinkR

LDlinkPy is intended to provide Python access to the major LDlink workflows familiar to LDlinkR users. Function names and behavior are generally aligned where practical, while using Python conventions such as pandas DataFrames and keyword arguments.

Development Status

This package is in its first public release series. Feedback from biomedical research users is welcome, especially on endpoint behavior, documentation clarity, and example workflows.

Metadata

Release files for ldlinkpy 0.4.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ldlinkpy 0.4.5
File Size Uploaded Provenance
ldlinkpy-0.4.5.tar.gz 50.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ldlinkpy 0.4.5
File Interpreter ABI Platform
ldlinkpy-0.4.5-py3-none-any.whl Python 3 none any Details

Total release size: 95.2 kB

Release files / ldlinkpy-0.4.5.tar.gz

Download URL ldlinkpy-0.4.5.tar.gz
Size 50.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a38448aa209ad45c09f15d7114a289bcc89e011e845ac3e3271c6bd5a754a238
BLAKE2b-256 checksum
How to use checksums
77df160846404db32bb524525e351ce49342a8e24566220c0d4d37152ab5a44f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.1

Release files / ldlinkpy-0.4.5-py3-none-any.whl

Download URL ldlinkpy-0.4.5-py3-none-any.whl
Size 45.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d0a812e8f58c3c62c3c80530016cc1d621b03adeda0db737d94e6eb1ec951d9
BLAKE2b-256 checksum
How to use checksums
d3cb9b1c75c788da45eeaf798b0a286695a1f6995625a1535621dc452ec77e90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.1

Security for ldlinkpy 0.4.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.4.5 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page