reactome-database について
reactome-databaseは、Reactomeの生物学的経路データの検索と富化解析を行うスキルです。公開REST APIを通じて、経路の探索、識別子の対応付け、遺伝子やタンパク質リストの解析を支援します。
主な機能
- 01安定IDによる経路とエンティティの検索
- 02キーワードによる生物学データ検索
- 03遺伝子リストの富化解析
- 04経路階層と反応の閲覧
- 05データベース間の識別子マッピング
活用シーン
- 01遺伝子リストで富化した経路の解析
- 02種ごとの経路や反応の検索
- 03経路内のエンティティと階層の探索
- 04マルチオミクスのワークフローへの経路情報追加
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ jaechang-hits/ sciagent-skills --skill reactome-databaseインストール後、Claude Code で/reactome-databaseを入力して読み込まれたか確認します。
詳細
Reactome Database — 生物学的パスウェイクエリとエンリッチメント解析
概要
Reactome は、16 種以上の生物種を対象とした、生物学的パスウェイと反応のオープンソースかつキュレーション済みのデータベースです。2 つの REST API を提供しています。1 つはパスウェイデータ、エンティティ、階層を検索する Content Service、もう 1 つは遺伝子/タンパク質リストのエンリッチメントと発現データのオーバーレイを行う Analysis Service です。すべてのエンドポイントは JSON(デフォルト)またはその他の形式で応答し、認証は不要です。
使用する場面
- 安定 ID(例:細胞周期を示す R-HSA-69620)でパスウェイの詳細を検索する
- キーワードでパスウェイ、反応、エンティティを検索する
- Reactome のパスウェイに対して遺伝子リストのエンリッチメント解析(過剰代表解析)を実行する
- パスウェイ階層と包含関係を取得する
- データベース間で識別子をマッピングする(UniProt、Ensembl、NCBI、ChEBI)
- 生物種固有のパスウェイデータを取得する(ヒト、マウス、ラット、その他 13 種以上の生物)
- トークンを使って解析結果を取得し、共有または再フィルタリングする
- マルチオミクス統合ワークフロー用のパスウェイコンテキストを構築する
- KEGG の代謝パスウェイとデータベース間の ID 変換には、代わりに
kegg-databaseを使用してください - タンパク質間相互作用ネットワークには、代わりに
string-database-ppiを使用してください - キャッシュ機能付き Python ラッパーをお探しの場合は、
reactome2py(pip install reactome2py)をご検討ください
前提条件
pip install requests
API の制約:
- 認証は不要です — すべてのエンドポイントは公開されています
- 文書化された厳格なレート制限はありません — 配慮のため、一括リクエストの間に
time.sleep(0.5)を追加してください - Content Service のベース URL:
https://reactome.org/ContentService - Analysis Service のベース URL:
https://reactome.org/AnalysisService - 入力可能な識別子:遺伝子/タンパク質リストでは、UniProt ID、Ensembl 遺伝子 ID、NCBI Gene ID、HGNC シンボル、ChEBI ID、miRBase ID、KEGG ID などを使用できます
クイックスタート
import requests
import time
CONTENT = "https://reactome.org/ContentService"
ANALYSIS = "https://reactome.org/AnalysisService"
def reactome_get(base, path, params=None):
"""Generic Reactome REST API caller. Returns JSON or raises."""
resp = requests.get(f"{base}{path}", params=params)
resp.raise_for_status()
try:
return resp.json()
except ValueError:
return resp.text
# Check database version
version = reactome_get(CONTENT, "/data/database/version")
print(f"Reactome version: {version}")
# Query a pathway
pathway = reactome_get(CONTENT, "/data/query/R-HSA-69620")
print(f"Pathway: {pathway['displayName']}")
print(f"Species: {pathway['speciesName']}")
time.sleep(0.5)
# Search for pathways
results = reactome_get(CONTENT, "/search/query", params={"query": "apoptosis", "types": "Pathway"})
print(f"Found {results['found']} results for 'apoptosis'")
コア API
1. パスウェイとエンティティの検索
安定 ID を使って、パスウェイ、反応、生物学的エンティティの詳細情報を取得します。クイックスタートの reactome_get ヘルパーを使用します。
# Query pathway by stable ID
pathway = reactome_get(CONTENT, "/data/query/R-HSA-69620")
print(f"Name: {pathway['displayName']}")
print(f"Stable ID: {pathway['stId']}, Species: {pathway['speciesName']}")
print(f"Schema class: {pathway['schemaClass']}") # Pathway, TopLevelPathway, etc.
time.sleep(0.5)
# Get participating physical entities in a pathway
entities = reactome_get(CONTENT, f"/data/participants/{pathway['stId']}")
print(f"\nParticipating entities: {len(entities)}")
for e in entities[:3]:
print(f" {e['displayName']} ({e['schemaClass']})")
time.sleep(0.5)
# Get participating molecules with reference entities (UniProt, ChEBI, etc.)
refs = reactome_get(CONTENT, f"/data/participants/{pathway['stId']}/referenceEntities")
print(f"\nReference entities: {len(refs)}")
for r in refs[:3]:
print(f" {r['displayName']} — {r.get('databaseName', 'N/A')}:{r.get('identifier', 'N/A')}")
2. 検索と探索
ファセットフィルタリングを使って、キーワードで Reactome 全体を検索します。
# Keyword search filtered to Pathways
results = reactome_get(CONTENT, "/search/query", params={
"query": "cell cycle",
"types": "Pathway",
"species": "Homo sapiens",
"cluster": "true"
})
print(f"Total found: {results['found']}")
for entry in results.get("results", [])[:1]:
for e in entry.get("entries", [])[:5]:
print(f" {e['stId']}: {e['name']}")
time.sleep(0.5)
# Search for proteins/complexes
proteins = reactome_get(CONTENT, "/search/query", params={
"query": "TP53", "types": "Protein", "species": "Homo sapiens"
})
print(f"\nTP53 protein entries: {proteins['found']}")
time.sleep(0.5)
# Suggest (autocomplete)
suggestions = reactome_get(CONTENT, "/search/suggest", params={"query": "apopt"})
print(f"Suggestions: {suggestions}")
検索可能なタイプ:Pathway、Reaction、Protein、Complex、SmallMolecule、Gene、DNA、RNA、Drug、ReferenceEntity
3. エンリッチメント解析
遺伝子/タンパク質リストを送信し、Reactome のパスウェイに対する過剰代表解析を実行します。
import requests
import time
ANALYSIS = "https://reactome.org/AnalysisService"
# Gene list (newline-separated identifiers — UniProt, HGNC symbols, Ensembl, etc.)
gene_list = "TP53\nBRCA1\nBRCA2\nATM\nCHEK2\nCDK2\nRB1\nMDM2\nCDKN1A\nBAX"
# Submit for enrichment (POST with text body)
resp = requests.post(
f"{ANALYSIS}/identifiers/",
headers={"Content-Type": "text/plain"},
data=gene_list,
params={"pageSize": 10, "page": 1, "sortBy": "ENTITIES_FDR", "order": "ASC"}
)
resp.raise_for_status()
result = resp.json()
print(f"Analysis token: {result['summary']['token']}")
print(f"Pathways found: {result['pathwaysFound']}")
print(f"Identifiers found: {result['identifiersNotFound']}")
print(f"\nTop enriched pathways:")
for p in result["pathways"][:5]:
print(f" {p['stId']}: {p['name']}")
print(f" FDR: {p['entities']['fdr']:.2e}, "
f"Found: {p['entities']['found']}/{p['entities']['total']}")
time.sleep(0.5)
解析で受け付ける形式:改行区切りの識別子、または発現値を含むタブ区切り(発現オーバーレイ用)。対応する ID には、UniProt、HGNC シンボル、Ensembl、NCBI Gene、ChEBI、miRBase、KEGG などがあります。
4. 解析結果とフィルタリング
トークンを使って以前に計算した解析結果を取得し、フィルターを適用します。
import requests
import time
ANALYSIS = "https://reactome.org/AnalysisService"
# Re-fetch results by token (from a previous analysis)
token = "MjAyNTA2MTcxMDA3MzRfMQ%3D%3D" # example — use token from Module 3
# Get results with filtering
results = requests.get(f"{ANALYSIS}/token/{token}", params={
"pageSize": 20,
"page": 1,
"sortBy": "ENTITIES_FDR",
"species": "Homo sapiens",
"resource": "TOTAL" # TOTAL, UNIPROT, ENSEMBL, CHEBI, etc.
})
results.raise_for_status()
data = results.json()
print(f"Token: {data['summary']['token']}")
print(f"Pathways: {data['pathwaysFound']}")
time.sleep(0.5)
# Get identifiers found in a specific pathway
pathway_detail = requests.get(
f"{ANALYSIS}/token/{token}/found/all/{data['pathways'][0]['stId']}"
)
pathway_detail.raise_for_status()
found = pathway_detail.json()
print(f"\nIdentifiers found in {data['pathways'][0]['name']}:")
for entity in found.get("entities", [])[:5]:
mapsTo = [m["identifier"] for m in entity.get("mapsTo", [])]
print(f" {entity['id']} -> {mapsTo}")
トークンの有効期間:解析トークンは数時間有効です。トークンを共有すると、共同作業者は解析を再実行せずに同じ結果を確認できます。resource(TOTAL、UNIPROT、ENSEMBL、CHEBI など)と species でフィルタリングできます。
5. パスウェイ階層とイベント
最上位のパスウェイから反応まで、Reactome のパスウェイ階層をたどります。
# Top-level pathways for human (9606 = NCBI taxonomy ID)
top = reactome_get(CONTENT, "/data/pathways/top/9606")
print(f"Top-level human pathways: {len(top)}")
for p in top[:5]:
print(f" {p['stId']}: {p['displayName']}")
time.sleep(0.5)
# Get contained events (sub-pathways and reactions)
events = reactome_get(CONTENT, "/data/pathway/R-HSA-69620/containedEvents")
print(f"\nContained events in Cell Cycle: {len(events)}")
for e in events[:5]:
print(f" {e['stId']}: {e['displayName']} ({e['schemaClass']})")
time.sleep(0.5)
# Get the full ancestor chain for a pathway
ancestors = reactome_get(CONTENT, "/data/event/R-HSA-69620/ancestors")
print(f"\nAncestors of Cell Cycle:")
for chain in ancestors:
names = [a["displayName"] for a in chain]
print(f" {' > '.join(names)}")
生物種の識別子:NCBI の分類 ID(9606=ヒト、10090=マウス、10116=ラット)または生物種名を使用します。
6. 相互参照と生物種
データベース間で識別子をマッピングし、生物種固有のデータを検索します。
# List all species in Reactome
species = reactome_get(CONTENT, "/data/species/all")
print(f"Species in Reactome: {len(species)}")
for s in species[:5]:
print(f" {s['displayName']} (taxId: {s['taxId']})")
time.sleep(0.5)
# Map a Reactome entity to external references
xrefs = reactome_get(CONTENT, "/data/query/R-HSA-69620/xrefs")
if isinstance(xrefs, list):
print(f"\nCross-references for R-HSA-69620: {len(xrefs)}")
for x in xrefs[:5]:
print(f" {x}")
time.sleep(0.5)
# Get orthologous pathway in another species (human → mouse)
mouse_ortho = reactome_get(CONTENT, "/data/orthology/R-HSA-69620/species/10090")
if mouse_ortho:
for o in mouse_ortho[:3]:
print(f"Mouse ortholog: {o['stId']}: {o['displayName']}")
主な概念
パスウェイ階層
Reactome は知識を階層構造で整理しています。
| レベル | スキーマクラス | 例 |
|---|---|---|
| 最上位パスウェイ | TopLevelPathway | 細胞周期、免疫系、代謝 |
| パスウェイ | Pathway | 細胞周期チェックポイント、有糸分裂の G1-G1/S 期 |
| 反応 | Reaction | TP53 が RB1 に結合する |
| 物理的エンティティ | EntityWithAccessionedSequence | TP53 [細胞質] |
パスウェイにはサブパスウェイと反応が含まれます。反応は入出力の物理的エンティティを結び付けます。各エンティティは参照データベース(UniProt、ChEBI、Ensembl)に対応付けられています。
対応している識別子
Analysis Service は幅広い識別子を受け付けます。
| データベース | ID の例 | 種類 |
|---|---|---|
| UniProt | P04637 | タンパク質 |
| HGNC Symbol | TP53 | 遺伝子シンボル |
| Ensembl Gene | ENSG00000141510 | 遺伝子 |
| NCBI Gene | 7157 | 遺伝子 |
| ChEBI | CHEBI:15377 | 小分子 |
| miRBase | hsa-miR-21-5p | マイクロRNA |
| KEGG Gene | hsa:7157 | 遺伝子(KEGG 形式) |
| Ensembl Protein | ENSP00000269305 | タンパク質 |
分析トークンシステム
分析を送信すると、Reactome はトークンを返します。これは結果セットを識別する URL 対応の文字列です。トークンを使うと、次のことができます。
- 分析を再実行せずに結果を再取得する(
GET /token/{token}) - 初回の分析後に、種やリソースで結果をフィルタリングする
- URL を使って共同研究者と結果を共有する:
https://reactome.org/PathwayBrowser/#/DTAB=AN&ANALYSIS={token} - トークンは数時間後に期限切れになります。必要に応じて遺伝子リストを再送信してください。
よくあるワークフロー
ワークフロー 1:遺伝子リストのエンリッチメントパイプライン
目的:遺伝子リストを送信してエンリッチメントされたパスウェイを取得し、上位の結果を調べます。
import requests
import time
CONTENT = "https://reactome.org/ContentService"
ANALYSIS = "https://reactome.org/AnalysisService"
# Step 1: Submit gene list
genes = "TP53\nBRCA1\nBRCA2\nATM\nCHEK2\nCDK2\nRB1\nMDM2\nCDKN1A\nBAX"
resp = requests.post(
f"{ANALYSIS}/identifiers/",
headers={"Content-Type": "text/plain"},
data=genes,
params={"pageSize": 5, "sortBy": "ENTITIES_FDR", "order": "ASC"}
)
resp.raise_for_status()
result = resp.json()
token = result["summary"]["token"]
print(f"Token: {token} | Pathways found: {result['pathwaysFound']}")
# Step 2: Show top pathways with FDR
for p in result["pathways"][:5]:
fdr = p["entities"]["fdr"]
ratio = f"{p['entities']['found']}/{p['entities']['total']}"
print(f" {p['stId']}: {p['name']} (FDR={fdr:.2e}, {ratio})")
time.sleep(0.5)
# Step 3: Get details on top pathway
top_id = result["pathways"][0]["stId"]
detail = requests.get(f"{CONTENT}/data/query/{top_id}").json()
print(f"\nTop pathway: {detail['displayName']}")
print(f"Compartments: {[c['displayName'] for c in detail.get('compartment', [])]}")
ワークフロー 2:パスウェイの探索
目的:上位レベルのパスウェイから、特定の反応やエンティティへとたどります。
# Uses reactome_get helper and CONTENT base URL from Quick Start
# Step 1: Find pathway by search
results = reactome_get(CONTENT, "/search/query",
params={"query": "DNA repair", "types": "Pathway", "species": "Homo sapiens"})
top_hit = results["results"][0]["entries"][0]
pid = top_hit["stId"]
print(f"Found: {pid} — {top_hit['name']}")
time.sleep(0.5)
# Step 2: Get sub-events
events = reactome_get(CONTENT, f"/data/pathway/{pid}/containedEvents")
reactions = [e for e in events if e["schemaClass"] == "Reaction"]
subpaths = [e for e in events if "Pathway" in e["schemaClass"]]
print(f"Sub-pathways: {len(subpaths)}, Reactions: {len(reactions)}")
time.sleep(0.5)
# Step 3: Get participating molecules for a reaction
if reactions:
rxn = reactions[0]
refs = reactome_get(CONTENT, f"/data/participants/{rxn['stId']}/referenceEntities")
print(f"\n{rxn['displayName']} participants:")
for r in refs[:5]:
print(f" {r.get('databaseName', '?')}:{r.get('identifier', '?')} — {r['displayName']}")
ワークフロー 3:発現データの分析
目的:パスウェイレベルの発現オーバーレイを行うため、識別子とともに発現値を送信します。
import requests
ANALYSIS = "https://reactome.org/AnalysisService"
# Tab-separated: identifier \t expression_value1 \t expression_value2 ...
# First line can be a header (auto-detected)
expression_data = """#id\tcontrol\ttreated
TP53\t1.2\t3.5
BRCA1\t2.1\t1.8
CDK2\t0.9\t4.2
RB1\t1.5\t0.6
MDM2\t1.0\t2.8
CDKN1A\t0.8\t5.1
BAX\t1.1\t3.9"""
resp = requests.post(
f"{ANALYSIS}/identifiers/",
headers={"Content-Type": "text/plain"},
data=expression_data,
params={"pageSize": 10, "sortBy": "ENTITIES_FDR"}
)
resp.raise_for_status()
result = resp.json()
print(f"Expression columns: {result['summary'].get('sampleName', 'N/A')}")
print(f"Token: {result['summary']['token']}")
for p in result["pathways"][:3]:
exp = p["entities"].get("exp", [])
print(f" {p['name']}: FDR={p['entities']['fdr']:.2e}, expr={exp}")
主なパラメーター
| パラメーター | 機能/エンドポイント | デフォルト | 選択肢 | 効果 |
|---|---|---|---|---|
query | /search/query | — | 任意の文字列 | キーワード検索語 |
types | /search/query | すべて | Pathway、Reaction、Protein など | スキーマクラスで検索を絞り込みます |
species | /search/query、分析 | すべて | 種名または分類群 ID | 対象生物を限定します |
pageSize | 分析、検索 | 20 | 1-250 | 1 ページあたりの結果数 |
sortBy | 分析 | ENTITIES_PVALUE | ENTITIES_FDR、ENTITIES_PVALUE、ENTITIES_FOUND、NAME | エンリッチメント結果を並べ替えます |
resource | 分析のフィルタリング | TOTAL | TOTAL、UNIPROT、ENSEMBL、CHEBI など | 識別子のソースでフィルタリングします |
cluster | /search/query | true | true、false | 検索結果を種類ごとにグループ化します |
ベストプラクティス
-
連続するリクエストの間に
time.sleep(0.5)を使用する:Reactome には明確に文書化されたハードレート制限はありませんが、短時間にリクエストを連続して送ると、スロットリングされる場合があります。共有リソースを適切に利用してください。 -
分析トークンを保存して再利用する:トークンは数時間有効です。トークンを保存しておけば、再送信せずに種やリソースで結果を再フィルタリングできます。
-
データベース ID より安定 ID を優先する:Reactome の安定 ID(R-HSA-69620)は永続的です。内部データベース ID は、リリースごとに変更される場合があります。
-
エンリッチメント結果には
sortBy=ENTITIES_FDRを使用する:FDR 補正済みの p 値は、パスウェイレベルの有意性を評価する際、生の p 値より信頼性が高くなります。 -
分析結果の
identifiersNotFoundを確認する:マッピングされなかった識別子が多い場合、識別子の種類が間違っているか、ID が古い可能性があります。
よく使うレシピ
レシピ:パスウェイ内のすべての遺伝子を取得する
import requests
CONTENT = "https://reactome.org/ContentService"
pathway_id = "R-HSA-69620" # Cell Cycle
refs = requests.get(f"{CONTENT}/data/participants/{pathway_id}/referenceEntities").json()
genes = set()
for r in refs:
if r.get("databaseName") == "UniProt":
genes.add(r.get("displayName", r.get("identifier")))
print(f"UniProt proteins in {pathway_id}: {len(genes)}")
for g in sorted(genes)[:10]:
print(f" {g}")
レシピ:パスウェイ図の URL
# Generate a direct link to the Reactome pathway diagram
pathway_id = "R-HSA-69620"
diagram_url = f"https://reactome.org/PathwayBrowser/#/{pathway_id}"
print(f"View diagram: {diagram_url}")
# With analysis overlay
token = "YOUR_TOKEN"
overlay_url = f"https://reactome.org/PathwayBrowser/#/{pathway_id}&DTAB=AN&ANALYSIS={token}"
print(f"View with analysis: {overlay_url}")
レシピ:パスウェイの一括クエリ
import requests
import time
CONTENT = "https://reactome.org/ContentService"
pathway_ids = ["R-HSA-69620", "R-HSA-109581", "R-HSA-1640170"]
summaries = []
for pid in pathway_ids:
resp = requests.get(f"{CONTENT}/data/query/{pid}")
resp.raise_for_status()
data = resp.json()
summaries.append({
"stId": data["stId"],
"name": data["displayName"],
"species": data["speciesName"],
"hasDiagram": data.get("hasDiagram", False)
})
time.sleep(0.5)
for s in summaries:
print(f"{s['stId']}: {s['name']} (diagram: {s['hasDiagram']})")
トラブルシューティング
| 問題 | 原因 | 解決策 |
|---|---|---|
404 Not Found | 無効な安定 ID、または誤った種のプレフィックス | ID の形式を確認してください。ヒトの場合は R-HSA-{number} を使用します。有効な ID を見つけるには /search/query を使用してください |
400 Bad Request | POST 本文の形式が不正、または Content-Type が誤っている | 解析には Content-Type: text/plain を使用し、識別子は改行で区切ってください |
| 解析結果が空 | 識別子が認識されていない | identifiersNotFound を確認し、別の ID 種類(UniProt と HGNC シンボルなど)を試してください |
500 Internal Server Error | サーバー側の問題、または入力が非常に大きい | 時間をおいて再試行してください。大きな遺伝子リスト(ID が 2000 件を超える場合)は、複数のバッチに分割してください |
| トークンの有効期限切れ | 解析結果を利用できなくなっている | 遺伝子リストを再送信してください。トークンの有効期間は数時間です |
| 種の結果が誤っている | 種のフィルターが適用されていない | 検索/解析に species=Homo sapiens パラメーターを追加してください |
| 応答が遅い | 多数のエンティティを含む大きなパスウェイ | pageSize を使用してページネーションし、結果をローカルにキャッシュしてください |
| クロスリファレンスの結果が空 | エンティティに外部データベースのマッピングがない | すべての Reactome エンティティに UniProt/Ensembl のマッピングがあるわけではありません。エンティティスキーマクラスを確認してください |
同梱リソース
このスキルには、以下のコンテンツが統合されています。
- API リファレンス(465 行):Content Service のエンドポイント(data/query、search、participants、pathway hierarchy、species、xrefs)と Analysis Service のエンドポイント(identifiers、token retrieval、filtering)は、Core API のモジュール 1~6 で扱っています。サポートされている識別子の種類は「主要な概念」に記載されています。応答形式の詳細とエラー処理は「トラブルシューティング」に記載されています。
- クエリスクリプト(286 行):ReactomeClient クラスのメソッド(query_pathway、get_pathway_entities、search_pathways、analyze_genes、get_analysis_by_token)は、Core API のコードブロックと「一般的なワークフロー」に組み込まれています。
関連スキル
- kegg-database — KEGG のパスウェイクエリと代謝ネットワークデータ。代謝パスウェイに焦点を当てる場合や、データベース間で ID を変換する場合に使用します
- string-database-ppi — STRING のタンパク質間相互作用ネットワーク。相互作用の根拠を加えることで、Reactome のパスウェイデータを補完します
- bioservices-multi-database —
bioservices.Reactomeを介して Reactome を含む 40 以上のデータベースにアクセスできる、統一された Python インターフェースです - cobrapy-metabolic-modeling — 制約ベースの代謝モデリング。FBA 解析の入力として Reactome のパスウェイデータを使用します
参考資料
- Reactome Content Service API — インタラクティブな API ドキュメント(Swagger)
- Reactome Analysis Service API — エンリッチメント解析 API のドキュメント
- Reactome website — パスウェイブラウザー、ダイアグラムビューアー、種の比較
- reactome2py — Reactome API の公式 Python ラッパー
- Gillespie, M. et al. (2022) "The reactome pathway knowledgebase 2022" Nucleic Acids Research 50:D364-D370