variant-population-frequency
Query gnomAD for variant allele frequency across populations. Uses FAVOR to convert rsID→variant_id first, then queries gnomAD.
- License 许可
- MIT
- 最近更新
- 2026-03-20
- Stars
- ★ 172
- Forks
- 10
01 前言 Front Matter
- name
- variant-population-frequency
- license
- MIT license
- metadata
- { "skill-author": "PJLab" }
- description
- Query gnomAD for variant allele frequency across populations. Uses FAVOR to convert rsID→variant_id first, then queries gnomAD.
02 资源文件 6
- 参考文档references/bioframe_migration.md7.2 KB
- 参考文档references/configuration.md4.7 KB
- 参考文档references/file_io.md12.0 KB
- 参考文档references/interval_operations.md12.0 KB
- 参考文档references/pileup_operations.md4.8 KB
- 参考文档references/sql_processing.md6.0 KB
03 SKILL.md 正文
gnomAD Population Frequency
Usage
Tool Description
Step 1: Query FAVOR to convert rsID → chr-pos-ref-alt format.
API: GET https://api.genohub.org/v1/rsids/{rs_id}
Step 2: Query gnomAD GraphQL API with the variant_id.
API: POST https://gnomad.broadinstitute.org/api (GraphQL)
Args:
rs_id (str): dbSNP rsID (e.g. "rs7412")
Return:
Overall AF, population-specific AF (exome + genome), homozygote counts.
Query Example
import requests
rs_id = "rs7412"
# ── Step 1: FAVOR 获取 variant_id (chr-pos-ref-alt) ──
# 注意:FAVOR 可能返回多个变异(多等位基因位点),需遍历所有结果
favor_url = f"https://api.genohub.org/v1/rsids/{rs_id}"
favor_resp = requests.get(favor_url, timeout=30).json()
if not isinstance(favor_resp, list):
favor_resp = [favor_resp]
variant_ids = [item.get("variant_vcf", "") for item in favor_resp if item.get("variant_vcf")]
print(f"[FAVOR] 该rsID对应 {len(variant_ids)} 个变异: {variant_ids}")
# ── Step 2: gnomAD 查询人群频率(遍历所有变异) ──
query = """
query VariantQuery($variantId: String!) {
variant(variantId: $variantId, dataset: gnomad_r4) {
variant_id
rsid
exome {
ac
an
af
ac_hom
populations { id ac an ac_hom }
}
genome {
ac
an
af
ac_hom
populations { id ac an ac_hom }
}
}
}
"""
for variant_vcf in variant_ids:
print(f"\n── 查询 {variant_vcf} ──")
resp = requests.post(
"https://gnomad.broadinstitute.org/api",
json={"query": query, "variables": {"variantId": variant_vcf}},
timeout=30
).json()
v = resp.get("data", {}).get("variant", {})
if not v:
print(f"[gnomAD] {variant_vcf}: 未找到数据")
continue
print(f"[gnomAD] variant: {v.get('variant_id')}, rsid: {v.get('rsid')}")
for source in ["exome", "genome"]:
d = v.get(source, {})
if d:
print(f"[gnomAD] {source}: AF={d.get('af')}, AC={d.get('ac')}, AN={d.get('an')}, Hom={d.get('ac_hom')}")
for pop in (d.get("populations") or []):
if pop.get("an", 0) > 0:
af = pop["ac"] / pop["an"]
print(f" {pop['id']}: AF={af:.6f}, AC={pop['ac']}, AN={pop['an']}")
04 同仓库更多 Skills
scientific-critical-thinking
Evaluate scientific claims and evidence quality. Use for assessing experimental design validity, identifying biases and confounders, applying evidence grading frameworks (GRADE, Cochrane Risk of Bias), or teaching critical analysis. Best for understanding evidence quality, identifying flaws. For formal peer review writing use peer-review.
scientific-brainstorming
Creative research ideation and exploration. Use for open-ended brainstorming sessions, exploring interdisciplinary connections, challenging assumptions, or identifying research gaps. Best for early-stage research planning when you do not have specific observations yet. For formulating testable hypotheses from data use hypothesis-generation.
scientific-literature-search
Search scientific literature and research papers using FlowSearch to find relevant academic articles and publications.
pubmed-article-search
Search PubMed database for scientific articles and publications to retrieve biomedical literature.
biomedical-web-search
Search biomedical literature and web content using Tavily search engine for research and clinical information.
uniprot-protein-retrieval
Retrieve protein sequences and functional information from UniProt database by protein name, enabling protein analysis and bioinformatics workflows.