Alterlab gwas

From AlterLab-IEU/AlterLab-Academic-Skills · View interactive version

Alterlab gwas is an AI agent skill from the GitHub repository AlterLab-IEU/AlterLab-Academic-Skills. Query the NHGRI-EBI GWAS Catalog REST API v2 for curated SNP-trait associations, retrieving variants by rs ID, disease/trait (EFO/MONDO), gene, or study (GCST) with p-values, effect sizes, and ancestry, and locate full harmonised summary statistics on the FTP site. Use when investigating genome-wide

How to use this skill

Skill file

GWAS Catalog Database

Overview

The GWAS Catalog is a curated repository of published genome-wide association studies maintained by NHGRI and EBI. It contains SNP-trait associations from thousands of GWAS publications — genetic variants, associated traits and diseases, p-values, effect sizes, and full summary statistics for many studies.

Scripts

scripts/query_gwas.py — query the GWAS Catalog REST API (stdlib only, JSON to stdout):

python scripts/query_gwas.py variant rs7903146                 # associations for a SNP (strongest first)
python scripts/query_gwas.py trait MONDO_0005148 --size 100    # associations for a trait
python scripts/query_gwas.py gene TCF7L2                       # associations mapped to a gene
python scripts/query_gwas.py find-trait "type 2 diabetes"      # free text -> efo_id
python scripts/query_gwas.py study GCST001795                  # study metadata (+ summary-stats FTP link)

When to Use This Skill

Use this skill for:

Does NOT Trigger

| Scenario | Use Instead |

|----------|-------------|

| Target-disease association scores, L2G / colocalisation evidence for drug targets | alterlab-opentargets |

| Clinical pathogenicity of a variant (ACMG/AMP, review stars) | alterlab-clinvar |

| Population allele frequencies or gene constraint | alterlab-gnomad |

| Which gene/tissue a variant regulates (eQTL/sQTL) | alterlab-gtex |

| Variant consequence (VEP), coordinates, gene models | alterlab-ensembl |

Hand-off rule. When the request matches a row above, open your answer by naming that skill by its exact id (for example alterlab-opentargets) and saying in one line why it fits better, then stop applying this skill's procedure. Name it even when you also need to ask for missing input. If only part of the request is out of scope, name the skill for that part and do only the in-scope part. A brief general pointer is fine; the named skill does the work.

Data Model

Four core entities, each with a canonical identifier:

Trait-ID gotcha (verified 2026-09): many traits have been re-mapped to MONDO / current EFO short-forms, and a stale ID returns an empty page rather than an error — associations?efo_id=EFO_0001360 (legacy type 2 diabetes) gives 0 rows while efo_id=MONDO_0005148 gives thousands. Resolve free text first with GET /v2/efo-traits?efo_trait=type 2 diabetes and use the returned efo_id. Older papers and pipelines may still cite the legacy EFO ID.

APIs

Core v2 endpoints: /v2/associations (filters rs_id, efo_id, efo_trait, mapped_gene, accession_id, pubmed_id; sort=p_value&direction=asc), /v2/studies and /v2/studies/{accession_id}, /v2/single-nucleotide-polymorphisms (by rs_id, mapped_gene, or chromosome + bp_start/bp_end), /v2/efo-traits, /v2/genes/{gene_name}. Responses are HAL+JSON with snake_case fields: results under _embedded.<resource> (associations, studies, snps, efo_traits), paging under page (totalElements, totalPages, number), next pages in _links.next.

Core Workflow

  1. Identify the entity — get the efo_id (trait; resolve free text via /v2/efo-traits?efo_trait=), rs ID (variant), GCST (study), or HGNC symbol (gene).
  2. Query the matching endpoint — trait/variant/study/gene/region; iterate pages via page/size or follow _links.next.
  3. Filter — by p-value (≤ 5×10⁻⁸ for genome-wide significance), ancestry, sample size, discovery/replication status.
  4. Extract — rs IDs and effect alleles (snp_allele[]), effect sizes (or_per_copy_num or the beta text), p-values. p_value underflows to 0.0 for very strong signals (rs7903146 in type 2 diabetes reaches 3×10⁻¹³¹⁵), so rank and report with pvalue_mantissa / pvalue_exponent.
  5. Cross-reference — Ensembl (consequences), gnomAD (frequencies), Open Targets, PGS Catalog.
  6. For genome-wide analyses — find studies with /v2/studies?efo_id=...&full_pvalue_set=true; each study's full_summary_stats field gives its FTP directory. Harmonised files live at https://ftp.ebi.ac.uk/pub/databases/gwas/summary_statistics/GCST<range>/<GCST>/harmonised/<GCST>.h.tsv.gz (GWAS-SSF columns, tabix-indexed .tbi), so a region can be pulled remotely with tabix <url> 10:112900000-113200000 instead of downloading the whole file. Don't scrape the association endpoints for this — they hold only curated top hits.

Routing Guidance

Reference Index

Citation and Resources

When using GWAS Catalog data, cite:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.