Skip to main content

Visualize GWAS-QTL colocalization events (Python port of the R package locuscomparer)

Project description

LocusComparePy locuscompare hex logo

📦 R users: the original R package is locuscomparer.

News

  • v0.1.0 (2026-07-08) — Initial Python port of locuscomparer, at feature parity with the R package v1.1.0: p-value / z-score (zscore_col) / logp_col input, custom LD via ld=, and the combined LocusCompare + LocusZoom figure via plotnine.

See NEWS.md for the full changelog.

1. Installation

LocusComparePy is a Python package for visualization of GWAS-eQTL colocalization events.

Install from PyPI (use the second line for the development version):

pip install locuscomparepy
# pip install git+https://github.com/boxiangliu/locuscomparepy

2. Example

To illustrate the use of locuscomparepy, we use the GWAS dataset from Nikpay et al. (2015) and the coronary artery eQTL dataset from GTEx v7 at the PHACTR1 locus:

import locuscompare as lc

gwas_fn = lc.example_path("gwas.tsv")
eqtl_fn = lc.example_path("eqtl.tsv")
fig = lc.locuscompare(in_fn1=gwas_fn, in_fn2=eqtl_fn,
                      title1="CAD GWAS", title2="Coronary Artery eQTL")
fig.save("locuscompare.png", width=10, height=5, dpi=150)

The output from locuscompare is a figure like the following:

The labeled SNP is the lead SNP (in this case for both studies), and other SNPs are colored according to their LD r² with the lead SNP.

3. Using your own dataset

The input to locuscompare() is a tab-delimited text file with two columns:

  1. rsid
  2. pval

Here is an example file:

rsid	pval
rs62156064	0.564395
rs7562234	0.399642
rs11677377	0.34308
rs35076156	0.625237

You can download the example files here: GWAS and eQTL datasets.

Then run the following commands:

import locuscompare as lc

gwas_fn = "path/to/gwas.tsv"
eqtl_fn = "path/to/eqtl.tsv"
fig = lc.locuscompare(in_fn1=gwas_fn, in_fn2=eqtl_fn, title1="GWAS", title2="eQTL")

You can also supply z-scores (zscore_col=) or pre-computed −log10(p) (logp_col=) instead of p-values, and bring your own LD via ld= (a SNP_A/SNP_B/R2 table) to bypass the reference database.

4. Documentation

To view documentation for each function, use help(function) (or function? in IPython/Jupyter). LocusComparePy exports the following functions:

Data munging

  • assign_color: Assign color to each SNP according to LD.
  • get_lead_snp: Get the lead SNP from the intersection of two studies.
  • get_position: Append two columns, chromosome (chr) and position (pos), to the input.

Plotting

  • locuscompare: Make a locuscompare plot.
  • make_combined_plot: Combine two locuszoom plots with a locuscompare plot.
  • make_locuszoom: Make a locuszoom plot.
  • make_scatterplot: Make a scatter plot (the LocusCompare plot).

Data loading

  • read_metal: Read association summary statistics from file.
  • retrieve_LD: Retrieve SNP pairwise LD from the database.
  • example_path: Path to a bundled example dataset (gwas.tsv, eqtl.tsv).

Position/LD lookups query a shared MySQL database over the network (non-standard port; some institutional firewalls may block it). Override the connection with LOCUSCOMPARE_DB_* environment variables.

5. Citation

If you use locuscompare, please cite the following paper: https://www.nature.com/articles/s41588-019-0404-0

Boxiang Liu, Michael J. Gloudemans, Abhiram S. Rao, Erik Ingelsson & Stephen B. Montgomery (2019) Abundant associations with gene expression complicate GWAS follow-up, Nature Genetics

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

locuscomparepy-0.1.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

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

locuscomparepy-0.1.0-py3-none-any.whl (113.2 kB view details)

Uploaded Python 3

File details

Details for the file locuscomparepy-0.1.0.tar.gz.

File metadata

  • Download URL: locuscomparepy-0.1.0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for locuscomparepy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 18133360714270885cbb18b630be944ed75c6932f06afd7c92a0d2bd473d424d
MD5 61d78430567ce0a800e57ccb3f5c5c03
BLAKE2b-256 0754e7e76b3ec36ee087a2f886839aac0fe132f06af91db8a99cb3512c52c2b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for locuscomparepy-0.1.0.tar.gz:

Publisher: publish.yml on boxiangliu/locuscomparepy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file locuscomparepy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: locuscomparepy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 113.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for locuscomparepy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 98f9a9a4753577d3aba1bb708c625e7d2087f656ab483af97687ea5ff6b0aa64
MD5 f16ae7f6985beca3971cbc44bab6ab0f
BLAKE2b-256 2cb20aa9539159e2386b5237342319f79857754830c00eac76ed5a49007386c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for locuscomparepy-0.1.0-py3-none-any.whl:

Publisher: publish.yml on boxiangliu/locuscomparepy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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