@nahisaho/satori 0.7.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -2
- package/package.json +1 -1
- package/src/.github/skills/scientific-admet-pharmacokinetics/SKILL.md +14 -0
- package/src/.github/skills/scientific-bayesian-statistics/SKILL.md +377 -0
- package/src/.github/skills/scientific-bioinformatics/SKILL.md +13 -0
- package/src/.github/skills/scientific-cheminformatics/SKILL.md +13 -0
- package/src/.github/skills/scientific-citation-checker/SKILL.md +12 -0
- package/src/.github/skills/scientific-clinical-decision-support/SKILL.md +14 -0
- package/src/.github/skills/scientific-deep-learning/SKILL.md +375 -0
- package/src/.github/skills/scientific-deep-research/SKILL.md +15 -0
- package/src/.github/skills/scientific-disease-research/SKILL.md +393 -0
- package/src/.github/skills/scientific-drug-repurposing/SKILL.md +14 -0
- package/src/.github/skills/scientific-drug-target-profiling/SKILL.md +14 -0
- package/src/.github/skills/scientific-explainable-ai/SKILL.md +357 -0
- package/src/.github/skills/scientific-grant-writing/SKILL.md +12 -0
- package/src/.github/skills/scientific-graph-neural-networks/SKILL.md +395 -0
- package/src/.github/skills/scientific-medical-imaging/SKILL.md +450 -0
- package/src/.github/skills/scientific-meta-analysis/SKILL.md +11 -0
- package/src/.github/skills/scientific-metabolomics/SKILL.md +13 -0
- package/src/.github/skills/scientific-multi-omics/SKILL.md +13 -0
- package/src/.github/skills/scientific-network-analysis/SKILL.md +13 -0
- package/src/.github/skills/scientific-pharmacovigilance/SKILL.md +516 -0
- package/src/.github/skills/scientific-precision-oncology/SKILL.md +424 -0
- package/src/.github/skills/scientific-protein-design/SKILL.md +13 -0
- package/src/.github/skills/scientific-protein-structure-analysis/SKILL.md +13 -0
- package/src/.github/skills/scientific-quantum-computing/SKILL.md +340 -0
- package/src/.github/skills/scientific-sequence-analysis/SKILL.md +13 -0
- package/src/.github/skills/scientific-survival-clinical/SKILL.md +12 -0
- package/src/.github/skills/scientific-variant-interpretation/SKILL.md +14 -0
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
## Overview
|
|
9
9
|
|
|
10
|
-
このディレクトリには、Exp-01〜13 で蓄積した科学データ解析技法を Agent Skills として体系化した **
|
|
10
|
+
このディレクトリには、Exp-01〜13 で蓄積した科学データ解析技法を Agent Skills として体系化した **56 個**のスキルを格納しています。Copilot がプロンプトの文脈に応じて適切なスキルを自動ロードし、各実験で確立した解析パターンを再利用します。22 のスキルは [ToolUniverse](https://github.com/mims-harvard/ToolUniverse) SMCP 経由で 1,200 以上の外部科学データベースツールとも連携可能です。
|
|
11
11
|
|
|
12
12
|
### パイプラインフロー
|
|
13
13
|
|
|
@@ -36,6 +36,24 @@ variant-interpretation → clinical-decision-support → presentation-design
|
|
|
36
36
|
|
|
37
37
|
各ステップで生成されるファイルが次のステップに自動的に引き継がれます:
|
|
38
38
|
|
|
39
|
+
**先端計算・医用パイプライン(P-S)**
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
pharmacovigilance ← admet-pharmacokinetics ← [P 安全性監視]
|
|
43
|
+
(市販後安全性) (前臨床 ADMET) ↓
|
|
44
|
+
precision-oncology → clinical-decision-support → medical-imaging
|
|
45
|
+
(腫瘍プロファイル) (臨床意思決定) (画像診断)
|
|
46
|
+
↓ ↓
|
|
47
|
+
disease-research → variant-interpretation → deep-learning
|
|
48
|
+
(疾患-遺伝子) (バリアント解釈) (DL フレームワーク)
|
|
49
|
+
↓
|
|
50
|
+
quantum-computing → bayesian-statistics → graph-neural-networks
|
|
51
|
+
(量子計算) (ベイズ推論) (GNN 分子予測)
|
|
52
|
+
↓
|
|
53
|
+
explainable-ai ← deep-learning ← [R 先端計算]
|
|
54
|
+
(XAI 説明可能性) (DL パイプライン)
|
|
55
|
+
```
|
|
56
|
+
|
|
39
57
|
| フェーズ | 生成ファイル | 参照先 |
|
|
40
58
|
|---|---|---|
|
|
41
59
|
| 仮説立案 | `docs/hypothesis.{md,json}`, `docs/workflow_design.{md,json}` | → scaffold, writing |
|
|
@@ -59,8 +77,34 @@ variant-interpretation → clinical-decision-support → presentation-design
|
|
|
59
77
|
| プレゼンテーション | `presentation/slides.md`, `presentation/poster.tex` | — |
|
|
60
78
|
| 研究方法論 | `docs/methodology_design.md`, `docs/study_design.json` | → grant-writing, doe |
|
|
61
79
|
| グラント | `grants/specific_aims.md`, `grants/research_strategy.md` | → hypothesis-pipeline |
|
|
80
|
+
| ファーマコビジランス | `results/pv_signal_report.{md,json}`, `figures/pv_temporal_trend.png` | → clinical-decision |
|
|
81
|
+
| 精密腫瘍学 | `results/mtb_report.{md,json}`, `results/variant_actionability.json` | → clinical-decision, writing |
|
|
82
|
+
| 疾患研究 | `results/disease_research_report.{md,json}`, `results/gwas_significant_loci.json` | → variant-interpretation |
|
|
83
|
+
| 量子計算 | `results/quantum_result.json`, `figures/quantum_convergence.png` | → bayesian, cheminformatics |
|
|
84
|
+
| GNN | `results/gnn_predictions.json`, `figures/gnn_training_curve.png` | → drug-target, admet |
|
|
85
|
+
| ベイズ統計 | `results/bayesian_summary.json`, `figures/bayesian_trace.png` | → doe, meta-analysis |
|
|
86
|
+
| 説明可能 AI | `results/xai_report.json`, `figures/shap_summary.png` | → clinical-decision |
|
|
87
|
+
| 深層学習 | `results/dl_training_log.json`, `models/model.onnx` | → GNN, medical-imaging |
|
|
88
|
+
| 医用イメージング | `results/imaging_report.{md,json}`, `results/radiomics_features.json` | → precision-oncology |
|
|
62
89
|
|
|
63
|
-
|
|
90
|
+
### ToolUniverse MCP ツール連携
|
|
91
|
+
|
|
92
|
+
22 のスキル(HIGH 13 + MEDIUM 9)は、[ToolUniverse](https://github.com/mims-harvard/ToolUniverse) SMCP サーバー経由で 1,200 以上の外部科学ツールを利用可能です。各 SKILL.md 内の `### 利用可能ツール` セクションに対応ツールが記載されています。
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
SATORI Skill (方法論・判断) ToolUniverse SMCP (データ取得・計算)
|
|
96
|
+
┌──────────────────────┐ ┌─────────────────────────────┐
|
|
97
|
+
│ pharmacovigilance │───MCP──│ FAERS, FDA Labels, DailyMed │
|
|
98
|
+
│ precision-oncology │───MCP──│ OncoKB, CIViC, COSMIC, GDC │
|
|
99
|
+
│ disease-research │───MCP──│ OpenTargets, HPO, Monarch │
|
|
100
|
+
│ drug-target-profiling│───MCP──│ UniProt, ChEMBL, DGIdb │
|
|
101
|
+
│ variant-interpretation│──MCP──│ ClinVar, gnomAD, ClinGen │
|
|
102
|
+
│ admet-pharmacokinetics│──MCP──│ ADMET-AI, PubChem, ChEMBL │
|
|
103
|
+
│ ... (22 skills total) │ │ ... (1,200+ tools) │
|
|
104
|
+
└──────────────────────┘ └─────────────────────────────┘
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
スキルは **19 の中区分**に分類されています。
|
|
64
108
|
|
|
65
109
|
| 中区分 | スキル数 | 概要 |
|
|
66
110
|
|---|:---:|---|
|
|
@@ -79,6 +123,10 @@ variant-interpretation → clinical-decision-support → presentation-design
|
|
|
79
123
|
| M. 実験室自動化 | 1 | 液体ハンドリング・プロトコル管理・ELN/LIMS 連携 |
|
|
80
124
|
| N. 科学プレゼンテーション | 1 | 科学スライド・ポスター・ワークフロー図 |
|
|
81
125
|
| O. 研究計画・グラント | 2 | 助成金申請書・研究方法論・倫理審査 |
|
|
126
|
+
| P. ファーマコビジランス | 1 | FAERS 不均衡分析・MedDRA 階層・安全性シグナル検出 |
|
|
127
|
+
| Q. 腫瘍学・疾患研究 | 2 | 精密腫瘍学 (CIViC/OncoKB)・疾患-遺伝子関連 (GWAS/Orphanet) |
|
|
128
|
+
| R. 量子・先端計算 | 5 | 量子計算・GNN・ベイズ統計・説明可能 AI・深層学習 |
|
|
129
|
+
| S. 医用イメージング | 1 | DICOM/NIfTI・WSI 病理画像・Radiomics・MONAI |
|
|
82
130
|
|
|
83
131
|
---
|
|
84
132
|
|
|
@@ -236,6 +284,43 @@ variant-interpretation → clinical-decision-support → presentation-design
|
|
|
236
284
|
| 46 | [scientific-grant-writing](scientific-grant-writing/SKILL.md) | NIH Specific Aims テンプレート・JSPS 科研費・予算計画・Budget Justification | 汎用 |
|
|
237
285
|
| 47 | [scientific-research-methodology](scientific-research-methodology/SKILL.md) | SCAMPER/TRIZ ブレインストーミング・研究デザインマトリクス・FINER 基準・IRB 倫理チェック | 汎用 |
|
|
238
286
|
|
|
287
|
+
### P. ファーマコビジランス(1 種)
|
|
288
|
+
|
|
289
|
+
市販後医薬品安全性監視のためのシグナル検出・定量評価を担うスキル。
|
|
290
|
+
|
|
291
|
+
| # | Skill | 説明 | 参照 Exp |
|
|
292
|
+
|---|---|---|---|
|
|
293
|
+
| 48 | [scientific-pharmacovigilance](scientific-pharmacovigilance/SKILL.md) | FAERS 不均衡分析 (PRR/ROR/IC/EBGM)・MedDRA 階層・時系列トレンド・Naranjo 因果評価 | 汎用 |
|
|
294
|
+
|
|
295
|
+
### Q. 腫瘍学・疾患研究(2 種)
|
|
296
|
+
|
|
297
|
+
精密腫瘍学と疾患-遺伝子関連研究を担うスキル群。
|
|
298
|
+
|
|
299
|
+
| # | Skill | 説明 | 参照 Exp |
|
|
300
|
+
|---|---|---|---|
|
|
301
|
+
| 49 | [scientific-precision-oncology](scientific-precision-oncology/SKILL.md) | CIViC/OncoKB/cBioPortal 統合・TMB/MSI 判定・AMP Tiering・MTB レポート | 汎用 |
|
|
302
|
+
| 50 | [scientific-disease-research](scientific-disease-research/SKILL.md) | GWAS Catalog・DisGeNET GDA・Orphanet/OMIM/HPO 表現型マッチング・PRS 算出 | 汎用 |
|
|
303
|
+
|
|
304
|
+
### R. 量子・先端計算(5 種)
|
|
305
|
+
|
|
306
|
+
量子計算・GNN・ベイズ統計・XAI・深層学習など次世代計算手法を担うスキル群。
|
|
307
|
+
|
|
308
|
+
| # | Skill | 説明 | 参照 Exp |
|
|
309
|
+
|---|---|---|---|
|
|
310
|
+
| 51 | [scientific-quantum-computing](scientific-quantum-computing/SKILL.md) | Qiskit/Cirq/PennyLane VQE・QAOA・量子 ML・QuTiP 量子ダイナミクス | 汎用 |
|
|
311
|
+
| 52 | [scientific-graph-neural-networks](scientific-graph-neural-networks/SKILL.md) | PyG GCN/GAT/GIN・TorchDrug 分子特性予測・知識グラフ推論・Scaffold Split | 汎用 |
|
|
312
|
+
| 53 | [scientific-bayesian-statistics](scientific-bayesian-statistics/SKILL.md) | PyMC/Stan 階層ベイズ・MCMC 診断・PPC・WAIC/LOO-CV モデル比較・ベイズ最適化 | 汎用 |
|
|
313
|
+
| 54 | [scientific-explainable-ai](scientific-explainable-ai/SKILL.md) | SHAP/LIME/Captum 特徴量寄与・反実仮想説明・公平性監査・DeepSHAP | 汎用 |
|
|
314
|
+
| 55 | [scientific-deep-learning](scientific-deep-learning/SKILL.md) | Lightning/timm/Transformers・CNN/ViT/BERT Fine-tune・Optuna HPO・ONNX エクスポート | 汎用 |
|
|
315
|
+
|
|
316
|
+
### S. 医用イメージング(1 種)
|
|
317
|
+
|
|
318
|
+
DICOM・WSI 等の医用画像の解析・セグメンテーションを担うスキル。
|
|
319
|
+
|
|
320
|
+
| # | Skill | 説明 | 参照 Exp |
|
|
321
|
+
|---|---|---|---|
|
|
322
|
+
| 56 | [scientific-medical-imaging](scientific-medical-imaging/SKILL.md) | DICOM/NIfTI 処理・MONAI U-Net/SwinUNETR・WSI パッチ抽出・Radiomics・3D 可視化 | 汎用 |
|
|
323
|
+
|
|
239
324
|
---
|
|
240
325
|
|
|
241
326
|
## インストール
|
|
@@ -357,6 +442,23 @@ Skills は `.github/skills/` に配置されているため、Copilot が自動
|
|
|
357
442
|
└── [O] 研究計画・グラント
|
|
358
443
|
├── scientific-grant-writing/
|
|
359
444
|
└── scientific-research-methodology/
|
|
445
|
+
│
|
|
446
|
+
├── [P] ファーマコビジランス
|
|
447
|
+
│ └── scientific-pharmacovigilance/
|
|
448
|
+
│
|
|
449
|
+
├── [Q] 腫瘍学・疾患研究
|
|
450
|
+
│ ├── scientific-precision-oncology/
|
|
451
|
+
│ └── scientific-disease-research/
|
|
452
|
+
│
|
|
453
|
+
├── [R] 量子・先端計算
|
|
454
|
+
│ ├── scientific-quantum-computing/
|
|
455
|
+
│ ├── scientific-graph-neural-networks/
|
|
456
|
+
│ ├── scientific-bayesian-statistics/
|
|
457
|
+
│ ├── scientific-explainable-ai/
|
|
458
|
+
│ └── scientific-deep-learning/
|
|
459
|
+
│
|
|
460
|
+
└── [S] 医用イメージング
|
|
461
|
+
└── scientific-medical-imaging/
|
|
360
462
|
```
|
|
361
463
|
|
|
362
464
|
> 注: 実際のファイルシステム上ではすべてのスキルディレクトリは `.github/skills/` 直下にフラットに配置されています。上記の中区分グルーピングは論理的な分類です。
|
package/package.json
CHANGED
|
@@ -350,6 +350,20 @@ def one_compartment_pk(dose, ka, ke, vd, time_points):
|
|
|
350
350
|
| `results/admet_report.md` | ADMET 評価レポート(Markdown) | 全解析完了時 |
|
|
351
351
|
| `results/pk_model.json` | PK モデルパラメータ(JSON) | PK モデリング完了時 |
|
|
352
352
|
|
|
353
|
+
### 利用可能ツール
|
|
354
|
+
|
|
355
|
+
> [ToolUniverse](https://github.com/mims-harvard/ToolUniverse) SMCP 経由で利用可能な外部ツール。
|
|
356
|
+
|
|
357
|
+
| カテゴリ | 主要ツール | 用途 |
|
|
358
|
+
|---|---|---|
|
|
359
|
+
| ADMET-AI | `ADMETAI_predict_BBB_penetrance` | BBB 透過性予測 |
|
|
360
|
+
| ADMET-AI | `ADMETAI_predict_CYP_interactions` | CYP 相互作用予測 |
|
|
361
|
+
| ADMET-AI | `ADMETAI_predict_toxicity` | 毒性予測 |
|
|
362
|
+
| ADMET-AI | `ADMETAI_predict_bioavailability` | バイオアベイラビリティ予測 |
|
|
363
|
+
| PubChem | `PubChem_get_compound_properties_by_CID` | 化合物物性取得 |
|
|
364
|
+
| ChEMBL | `ChEMBL_get_molecule` | 分子情報取得 |
|
|
365
|
+
| ChEMBL | `ChEMBL_get_activity` | バイオアッセイデータ |
|
|
366
|
+
|
|
353
367
|
### 参照スキル
|
|
354
368
|
|
|
355
369
|
| スキル | 連携 |
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: scientific-bayesian-statistics
|
|
3
|
+
description: |
|
|
4
|
+
ベイズ統計スキル。PyMC・Stan・ArviZ を活用し、ベイズ回帰・階層モデル・
|
|
5
|
+
MCMC サンプリング・ベイズ最適化・事後予測チェック・モデル比較を支援。
|
|
6
|
+
「ベイズ回帰して」「MCMC で推定して」「事後分布を求めて」で発火。
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Scientific Bayesian Statistics
|
|
10
|
+
|
|
11
|
+
ベイズ統計推論のための解析スキル。確率的プログラミング
|
|
12
|
+
フレームワーク(PyMC, Stan, NumPyro)を活用した
|
|
13
|
+
パラメータ推定・モデル比較・意思決定支援を行う。
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
- パラメータの事後分布推定
|
|
18
|
+
- 階層ベイズモデル(マルチレベル・混合効果)
|
|
19
|
+
- ベイズ回帰・ベイズ分類
|
|
20
|
+
- MCMC 診断(Rhat, ESS, トレースプロット)
|
|
21
|
+
- モデル比較(WAIC, LOO-CV, ベイズファクター)
|
|
22
|
+
- ベイズ最適化(Gaussian Process)
|
|
23
|
+
- 事後予測チェック
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### ベイズ解析パイプライン
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
Phase 1: Model Specification
|
|
31
|
+
- 尤度関数の選択 (Normal, Poisson, Binomial, etc.)
|
|
32
|
+
- 事前分布の設定 (弱情報事前分布推奨)
|
|
33
|
+
- パラメータ空間の定義
|
|
34
|
+
↓
|
|
35
|
+
Phase 2: Prior Predictive Check
|
|
36
|
+
- 事前予測シミュレーション
|
|
37
|
+
- 事前分布の妥当性検証
|
|
38
|
+
- ドメイン知識との整合性確認
|
|
39
|
+
↓
|
|
40
|
+
Phase 3: MCMC Sampling
|
|
41
|
+
- NUTS (No-U-Turn Sampler) 実行
|
|
42
|
+
- チェーン数・サンプル数設定 (chains≥4, draws≥2000)
|
|
43
|
+
- 収束診断 (Rhat < 1.01, ESS > 400)
|
|
44
|
+
↓
|
|
45
|
+
Phase 4: Posterior Analysis
|
|
46
|
+
- 事後分布可視化 (forest, trace, pair plot)
|
|
47
|
+
- 95% HDI (Highest Density Interval)
|
|
48
|
+
- 事後予測チェック (PPC)
|
|
49
|
+
↓
|
|
50
|
+
Phase 5: Model Comparison
|
|
51
|
+
- WAIC / LOO-CV 算出
|
|
52
|
+
- Bayes Factor 計算
|
|
53
|
+
- モデル重み付け平均 (Stacking)
|
|
54
|
+
↓
|
|
55
|
+
Phase 6: Reporting
|
|
56
|
+
- 推定値サマリーテーブル
|
|
57
|
+
- 事後分布プロット
|
|
58
|
+
- 結果の解釈・レポート生成
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Workflow
|
|
62
|
+
|
|
63
|
+
### 1. PyMC: ベイズ線形回帰
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
import pymc as pm
|
|
67
|
+
import arviz as az
|
|
68
|
+
import numpy as np
|
|
69
|
+
import matplotlib.pyplot as plt
|
|
70
|
+
|
|
71
|
+
# === データ生成 (例) ===
|
|
72
|
+
np.random.seed(42)
|
|
73
|
+
N = 100
|
|
74
|
+
X = np.random.randn(N)
|
|
75
|
+
true_alpha, true_beta, true_sigma = 1.0, 2.5, 0.5
|
|
76
|
+
y = true_alpha + true_beta * X + np.random.normal(0, true_sigma, N)
|
|
77
|
+
|
|
78
|
+
# === ベイズ線形回帰 ===
|
|
79
|
+
with pm.Model() as linear_model:
|
|
80
|
+
# 事前分布
|
|
81
|
+
alpha = pm.Normal("alpha", mu=0, sigma=10)
|
|
82
|
+
beta = pm.Normal("beta", mu=0, sigma=10)
|
|
83
|
+
sigma = pm.HalfNormal("sigma", sigma=5)
|
|
84
|
+
|
|
85
|
+
# 尤度
|
|
86
|
+
mu = alpha + beta * X
|
|
87
|
+
y_obs = pm.Normal("y_obs", mu=mu, sigma=sigma, observed=y)
|
|
88
|
+
|
|
89
|
+
# MCMC サンプリング (NUTS)
|
|
90
|
+
trace = pm.sample(
|
|
91
|
+
draws=2000,
|
|
92
|
+
tune=1000,
|
|
93
|
+
chains=4,
|
|
94
|
+
cores=4,
|
|
95
|
+
target_accept=0.95,
|
|
96
|
+
return_inferencedata=True,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
# === 収束診断 ===
|
|
100
|
+
print(az.summary(trace, var_names=["alpha", "beta", "sigma"]))
|
|
101
|
+
# Rhat < 1.01 && ESS > 400 を確認
|
|
102
|
+
|
|
103
|
+
# === トレースプロット ===
|
|
104
|
+
az.plot_trace(trace, var_names=["alpha", "beta", "sigma"])
|
|
105
|
+
plt.savefig("figures/bayesian_trace.png", dpi=300, bbox_inches="tight")
|
|
106
|
+
plt.show()
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 2. 階層ベイズモデル(マルチレベル)
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
import pandas as pd
|
|
113
|
+
|
|
114
|
+
# === 階層ベイズ回帰 (ランダム効果) ===
|
|
115
|
+
# 例: 複数学校の生徒の成績予測
|
|
116
|
+
# school_id: グループ変数
|
|
117
|
+
# x: 予測変数, y: 目的変数
|
|
118
|
+
|
|
119
|
+
def hierarchical_model(df):
|
|
120
|
+
school_ids = df["school_id"].unique()
|
|
121
|
+
school_idx = df["school_id"].map({s: i for i, s in enumerate(school_ids)}).values
|
|
122
|
+
n_schools = len(school_ids)
|
|
123
|
+
|
|
124
|
+
with pm.Model() as hier_model:
|
|
125
|
+
# Hyper-priors (全体平均)
|
|
126
|
+
mu_alpha = pm.Normal("mu_alpha", mu=0, sigma=10)
|
|
127
|
+
sigma_alpha = pm.HalfNormal("sigma_alpha", sigma=5)
|
|
128
|
+
mu_beta = pm.Normal("mu_beta", mu=0, sigma=10)
|
|
129
|
+
sigma_beta = pm.HalfNormal("sigma_beta", sigma=5)
|
|
130
|
+
|
|
131
|
+
# 学校レベルのパラメータ (部分プーリング)
|
|
132
|
+
alpha = pm.Normal("alpha", mu=mu_alpha, sigma=sigma_alpha, shape=n_schools)
|
|
133
|
+
beta = pm.Normal("beta", mu=mu_beta, sigma=sigma_beta, shape=n_schools)
|
|
134
|
+
|
|
135
|
+
# 残差
|
|
136
|
+
sigma = pm.HalfNormal("sigma", sigma=5)
|
|
137
|
+
|
|
138
|
+
# 尤度
|
|
139
|
+
mu = alpha[school_idx] + beta[school_idx] * df["x"].values
|
|
140
|
+
y_obs = pm.Normal("y_obs", mu=mu, sigma=sigma, observed=df["y"].values)
|
|
141
|
+
|
|
142
|
+
# サンプリング
|
|
143
|
+
trace = pm.sample(2000, tune=1000, chains=4, target_accept=0.95,
|
|
144
|
+
return_inferencedata=True)
|
|
145
|
+
|
|
146
|
+
return trace
|
|
147
|
+
|
|
148
|
+
# === Forest Plot(学校間パラメータ比較)===
|
|
149
|
+
# az.plot_forest(trace, var_names=["alpha", "beta"], combined=True)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 3. 事後予測チェック (PPC)
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
def posterior_predictive_check(model, trace, observed_y):
|
|
156
|
+
"""事後予測チェック: モデルの適合度検証"""
|
|
157
|
+
with model:
|
|
158
|
+
ppc = pm.sample_posterior_predictive(trace, random_seed=42)
|
|
159
|
+
|
|
160
|
+
fig, axes = plt.subplots(1, 3, figsize=(16, 5))
|
|
161
|
+
|
|
162
|
+
# 1. 密度オーバーレイ
|
|
163
|
+
az.plot_ppc(az.from_pymc3(posterior_predictive=ppc, model=model),
|
|
164
|
+
ax=axes[0], kind="kde")
|
|
165
|
+
axes[0].set_title("Posterior Predictive: KDE")
|
|
166
|
+
|
|
167
|
+
# 2. 統計量比較 (mean)
|
|
168
|
+
ppc_mean = ppc.posterior_predictive["y_obs"].mean(dim=("chain", "draw")).values
|
|
169
|
+
axes[1].hist(ppc_mean, bins=30, alpha=0.7, label="PPC mean")
|
|
170
|
+
axes[1].axvline(observed_y.mean(), color="red", linestyle="--", label="Observed mean")
|
|
171
|
+
axes[1].set_title("PPC: Mean Comparison")
|
|
172
|
+
axes[1].legend()
|
|
173
|
+
|
|
174
|
+
# 3. 残差チェック
|
|
175
|
+
ppc_median = np.median(ppc.posterior_predictive["y_obs"].values, axis=(0, 1))
|
|
176
|
+
residuals = observed_y - ppc_median
|
|
177
|
+
axes[2].scatter(ppc_median, residuals, alpha=0.5, s=10)
|
|
178
|
+
axes[2].axhline(0, color="red", linestyle="--")
|
|
179
|
+
axes[2].set_title("PPC Residuals")
|
|
180
|
+
|
|
181
|
+
plt.tight_layout()
|
|
182
|
+
plt.savefig("figures/bayesian_ppc.png", dpi=300, bbox_inches="tight")
|
|
183
|
+
plt.show()
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### 4. モデル比較 (WAIC / LOO-CV)
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
def bayesian_model_comparison(models_dict):
|
|
190
|
+
"""
|
|
191
|
+
WAIC / LOO-CV でベイズモデルを比較。
|
|
192
|
+
models_dict: {"model_name": (model, trace)} の辞書
|
|
193
|
+
"""
|
|
194
|
+
comparison_data = {}
|
|
195
|
+
|
|
196
|
+
for name, (model, trace) in models_dict.items():
|
|
197
|
+
# WAIC
|
|
198
|
+
waic = az.waic(trace)
|
|
199
|
+
# LOO-CV (PSIS-LOO)
|
|
200
|
+
loo = az.loo(trace)
|
|
201
|
+
|
|
202
|
+
comparison_data[name] = {
|
|
203
|
+
"waic": round(waic.waic, 2),
|
|
204
|
+
"waic_se": round(waic.waic_se, 2),
|
|
205
|
+
"p_waic": round(waic.p_waic, 2),
|
|
206
|
+
"loo": round(loo.loo, 2),
|
|
207
|
+
"loo_se": round(loo.loo_se, 2),
|
|
208
|
+
"p_loo": round(loo.p_loo, 2),
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
# ArviZ モデル比較
|
|
212
|
+
comp_df = az.compare(
|
|
213
|
+
{name: trace for name, (_, trace) in models_dict.items()},
|
|
214
|
+
ic="loo",
|
|
215
|
+
)
|
|
216
|
+
print("Model Comparison (LOO-CV):")
|
|
217
|
+
print(comp_df)
|
|
218
|
+
|
|
219
|
+
# 比較プロット
|
|
220
|
+
az.plot_compare(comp_df)
|
|
221
|
+
plt.savefig("figures/bayesian_model_comparison.png", dpi=300, bbox_inches="tight")
|
|
222
|
+
plt.show()
|
|
223
|
+
|
|
224
|
+
return comparison_data
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### 5. ベイズ最適化 (Gaussian Process)
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
from sklearn.gaussian_process import GaussianProcessRegressor
|
|
231
|
+
from sklearn.gaussian_process.kernels import Matern
|
|
232
|
+
from scipy.optimize import minimize
|
|
233
|
+
from scipy.stats import norm
|
|
234
|
+
|
|
235
|
+
def bayesian_optimization(objective_func, bounds, n_init=5, n_iter=25):
|
|
236
|
+
"""
|
|
237
|
+
Gaussian Process ベースのベイズ最適化。
|
|
238
|
+
Expected Improvement (EI) を獲得関数として使用。
|
|
239
|
+
"""
|
|
240
|
+
dim = len(bounds)
|
|
241
|
+
|
|
242
|
+
# 初期サンプリング (Latin Hypercube)
|
|
243
|
+
X_samples = np.random.uniform(
|
|
244
|
+
[b[0] for b in bounds],
|
|
245
|
+
[b[1] for b in bounds],
|
|
246
|
+
size=(n_init, dim)
|
|
247
|
+
)
|
|
248
|
+
y_samples = np.array([objective_func(x) for x in X_samples])
|
|
249
|
+
|
|
250
|
+
# GP モデル
|
|
251
|
+
kernel = Matern(nu=2.5)
|
|
252
|
+
gp = GaussianProcessRegressor(kernel=kernel, alpha=1e-6, normalize_y=True)
|
|
253
|
+
|
|
254
|
+
history = {"X": list(X_samples), "y": list(y_samples)}
|
|
255
|
+
|
|
256
|
+
for i in range(n_iter):
|
|
257
|
+
gp.fit(np.array(history["X"]), np.array(history["y"]))
|
|
258
|
+
|
|
259
|
+
# Expected Improvement
|
|
260
|
+
def neg_ei(x):
|
|
261
|
+
mu, sigma = gp.predict(x.reshape(1, -1), return_std=True)
|
|
262
|
+
best_y = np.min(history["y"])
|
|
263
|
+
z = (best_y - mu) / (sigma + 1e-8)
|
|
264
|
+
ei = (best_y - mu) * norm.cdf(z) + sigma * norm.pdf(z)
|
|
265
|
+
return -ei[0]
|
|
266
|
+
|
|
267
|
+
# 次の探索点
|
|
268
|
+
best_x = None
|
|
269
|
+
best_ei = np.inf
|
|
270
|
+
for _ in range(20):
|
|
271
|
+
x0 = np.random.uniform([b[0] for b in bounds], [b[1] for b in bounds])
|
|
272
|
+
result = minimize(neg_ei, x0, bounds=bounds, method="L-BFGS-B")
|
|
273
|
+
if result.fun < best_ei:
|
|
274
|
+
best_ei = result.fun
|
|
275
|
+
best_x = result.x
|
|
276
|
+
|
|
277
|
+
new_y = objective_func(best_x)
|
|
278
|
+
history["X"].append(best_x)
|
|
279
|
+
history["y"].append(new_y)
|
|
280
|
+
|
|
281
|
+
print(f"Iter {i+1}: x = {best_x}, y = {new_y:.4f}, best = {min(history['y']):.4f}")
|
|
282
|
+
|
|
283
|
+
return history
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### 6. Stan によるモデリング
|
|
287
|
+
|
|
288
|
+
```python
|
|
289
|
+
# === CmdStanPy インターフェース ===
|
|
290
|
+
import cmdstanpy
|
|
291
|
+
|
|
292
|
+
def fit_stan_model(stan_code, data_dict, **kwargs):
|
|
293
|
+
"""Stan モデルのコンパイルとフィット"""
|
|
294
|
+
model = cmdstanpy.CmdStanModel(stan_file=None, stan_file_path=None,
|
|
295
|
+
model_code=stan_code)
|
|
296
|
+
fit = model.sample(data=data_dict, chains=4, iter_sampling=2000,
|
|
297
|
+
iter_warmup=1000, **kwargs)
|
|
298
|
+
|
|
299
|
+
# ArviZ 変換
|
|
300
|
+
idata = az.from_cmdstanpy(fit)
|
|
301
|
+
return idata
|
|
302
|
+
|
|
303
|
+
# Stan モデルコード例: 階層正規モデル
|
|
304
|
+
STAN_HIERARCHICAL = """
|
|
305
|
+
data {
|
|
306
|
+
int<lower=0> N;
|
|
307
|
+
int<lower=0> J;
|
|
308
|
+
array[N] int<lower=1,upper=J> group;
|
|
309
|
+
vector[N] x;
|
|
310
|
+
vector[N] y;
|
|
311
|
+
}
|
|
312
|
+
parameters {
|
|
313
|
+
real mu_alpha;
|
|
314
|
+
real mu_beta;
|
|
315
|
+
real<lower=0> sigma_alpha;
|
|
316
|
+
real<lower=0> sigma_beta;
|
|
317
|
+
real<lower=0> sigma;
|
|
318
|
+
vector[J] alpha;
|
|
319
|
+
vector[J] beta;
|
|
320
|
+
}
|
|
321
|
+
model {
|
|
322
|
+
mu_alpha ~ normal(0, 10);
|
|
323
|
+
mu_beta ~ normal(0, 10);
|
|
324
|
+
sigma_alpha ~ half_normal(5);
|
|
325
|
+
sigma_beta ~ half_normal(5);
|
|
326
|
+
sigma ~ half_normal(5);
|
|
327
|
+
alpha ~ normal(mu_alpha, sigma_alpha);
|
|
328
|
+
beta ~ normal(mu_beta, sigma_beta);
|
|
329
|
+
y ~ normal(alpha[group] + beta[group] .* x, sigma);
|
|
330
|
+
}
|
|
331
|
+
"""
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Best Practices
|
|
337
|
+
|
|
338
|
+
1. **弱情報事前分布**: データに語らせる。過度に情報的な事前分布は避ける
|
|
339
|
+
2. **収束診断必須**: Rhat < 1.01, ESS > 400/chain, 発散なし
|
|
340
|
+
3. **事後予測チェック**: モデルの適合度を必ず PPC で検証
|
|
341
|
+
4. **LOO-CV 優先**: モデル比較は WAIC より LOO-CV (PSIS-LOO) が安定
|
|
342
|
+
5. **中心化パラメトリゼーション**: 階層モデルでは non-centered parameterization を検討
|
|
343
|
+
6. **再現性**: random_seed を固定
|
|
344
|
+
7. **感度分析**: 事前分布を変えた結果の安定性を確認
|
|
345
|
+
|
|
346
|
+
## Completeness Checklist
|
|
347
|
+
|
|
348
|
+
- [ ] モデル仕様 (尤度・事前分布) の定義
|
|
349
|
+
- [ ] Prior predictive check
|
|
350
|
+
- [ ] MCMC サンプリング完了
|
|
351
|
+
- [ ] 収束診断 (Rhat, ESS, divergences)
|
|
352
|
+
- [ ] 事後分布の要約 (mean, HDI)
|
|
353
|
+
- [ ] 事後予測チェック (PPC)
|
|
354
|
+
- [ ] モデル比較 (LOO-CV / WAIC)
|
|
355
|
+
- [ ] 結果レポート・プロット生成
|
|
356
|
+
|
|
357
|
+
## References
|
|
358
|
+
|
|
359
|
+
### Output Files
|
|
360
|
+
|
|
361
|
+
| ファイル | 形式 | 生成タイミング |
|
|
362
|
+
|---|---|---|
|
|
363
|
+
| `results/bayesian_summary.json` | 事後分布サマリー(JSON) | サンプリング完了時 |
|
|
364
|
+
| `figures/bayesian_trace.png` | トレースプロット | MCMC 完了時 |
|
|
365
|
+
| `figures/bayesian_ppc.png` | 事後予測チェック図 | PPC 完了時 |
|
|
366
|
+
| `figures/bayesian_model_comparison.png` | モデル比較プロット | 比較完了時 |
|
|
367
|
+
|
|
368
|
+
### 参照スキル
|
|
369
|
+
|
|
370
|
+
| スキル | 連携 |
|
|
371
|
+
|---|---|
|
|
372
|
+
| `scientific-statistical-testing` | ← 頻度論検定との比較基盤 |
|
|
373
|
+
| `scientific-ml-regression` | ← 回帰モデルのベイズ拡張 |
|
|
374
|
+
| `scientific-doe` | ← 実験計画のベイズ最適化 |
|
|
375
|
+
| `scientific-causal-inference` | ← ベイズ因果モデル |
|
|
376
|
+
| `scientific-quantum-computing` | → VQE パラメータのベイズ最適化 |
|
|
377
|
+
| `scientific-meta-analysis` | ← ベイズメタ分析 |
|
|
@@ -212,6 +212,19 @@ def metabolomics_preprocessing(df, metabolite_cols, group_col=None):
|
|
|
212
212
|
| `figures/umap_clusters.png` | PNG |
|
|
213
213
|
| `figures/network_visualization.png` | PNG |
|
|
214
214
|
|
|
215
|
+
### 利用可能ツール
|
|
216
|
+
|
|
217
|
+
> [ToolUniverse](https://github.com/mims-harvard/ToolUniverse) SMCP 経由で利用可能な外部ツール。
|
|
218
|
+
|
|
219
|
+
| カテゴリ | 主要ツール | 用途 |
|
|
220
|
+
|---|---|---|
|
|
221
|
+
| MyGene | `MyGene_get_gene_annotation` | 遺伝子アノテーション |
|
|
222
|
+
| UniProt | `UniProt_search` | タンパク質検索 |
|
|
223
|
+
| KEGG | `kegg_get_pathway_info` | パスウェイ情報取得 |
|
|
224
|
+
| Reactome | `Reactome_map_uniprot_to_pathways` | UniProt→パスウェイマッピング |
|
|
225
|
+
| GO | `GO_get_annotations_for_gene` | GO アノテーション |
|
|
226
|
+
| GEO | `geo_search_datasets` | 発現データセット検索 |
|
|
227
|
+
|
|
215
228
|
#### 参照実験
|
|
216
229
|
|
|
217
230
|
- **Exp-01**: scRNA-seq(Scanpy + PyDESeq2 + KEGG)
|
|
@@ -190,6 +190,19 @@ def scaffold_analysis(smiles_list, names=None):
|
|
|
190
190
|
| `figures/chemical_space_pca.png` | PNG |
|
|
191
191
|
| `figures/similarity_heatmap.png` | PNG |
|
|
192
192
|
|
|
193
|
+
### 利用可能ツール
|
|
194
|
+
|
|
195
|
+
> [ToolUniverse](https://github.com/mims-harvard/ToolUniverse) SMCP 経由で利用可能な外部ツール。
|
|
196
|
+
|
|
197
|
+
| カテゴリ | 主要ツール | 用途 |
|
|
198
|
+
|---|---|---|
|
|
199
|
+
| PubChem | `PubChem_get_CID_by_compound_name` | 化合物名→CID 変換 |
|
|
200
|
+
| PubChem | `PubChem_get_compound_properties_by_CID` | 化合物物性取得 |
|
|
201
|
+
| PubChem | `PubChem_search_compounds_by_similarity` | 類似化合物検索 |
|
|
202
|
+
| ChEMBL | `ChEMBL_search_molecules` | 分子検索 |
|
|
203
|
+
| ChEMBL | `ChEMBL_get_molecule` | 分子情報取得 |
|
|
204
|
+
| ZINC | `ZINC_search_by_smiles` | SMILES ベース検索 |
|
|
205
|
+
|
|
193
206
|
#### 参照実験
|
|
194
207
|
|
|
195
208
|
- **Exp-02**: EGFR 阻害剤 SAR 解析(記述子、Tanimoto、MCS、Scaffold)
|
|
@@ -418,6 +418,18 @@ def run_citation_check(manuscript_path, citation_style="numeric", filepath=None)
|
|
|
418
418
|
|---|---|---|
|
|
419
419
|
| `manuscript/citation_report.json` | JSON レポート | チェック完了時 |
|
|
420
420
|
|
|
421
|
+
### 利用可能ツール
|
|
422
|
+
|
|
423
|
+
> [ToolUniverse](https://github.com/mims-harvard/ToolUniverse) SMCP 経由で利用可能な外部ツール。
|
|
424
|
+
|
|
425
|
+
| カテゴリ | 主要ツール | 用途 |
|
|
426
|
+
|---|---|---|
|
|
427
|
+
| PubMed | `PubMed_search_articles` | 引用元論文の実在確認 |
|
|
428
|
+
| PubMed | `PubMed_get_article` | 論文メタデータ取得 |
|
|
429
|
+
| Crossref | `Crossref_get_work` | DOI バリデーション |
|
|
430
|
+
| Crossref | `Crossref_search_works` | 出版情報検索 |
|
|
431
|
+
| EuropePMC | `EuropePMC_search_articles` | ヨーロッパ文献確認 |
|
|
432
|
+
|
|
421
433
|
### 検出項目一覧
|
|
422
434
|
|
|
423
435
|
| チェック項目 | 説明 | 重要度 |
|
|
@@ -275,6 +275,20 @@ Clinical decisions must be made by qualified healthcare professionals.
|
|
|
275
275
|
| `results/clinical_recommendation.json` | 推奨事項データ(JSON) | GRADE 評価完了時 |
|
|
276
276
|
| `results/trial_matches.json` | 臨床試験マッチング結果(JSON) | 試験検索完了時 |
|
|
277
277
|
|
|
278
|
+
### 利用可能ツール
|
|
279
|
+
|
|
280
|
+
> [ToolUniverse](https://github.com/mims-harvard/ToolUniverse) SMCP 経由で利用可能な外部ツール。
|
|
281
|
+
|
|
282
|
+
| カテゴリ | 主要ツール | 用途 |
|
|
283
|
+
|---|---|---|
|
|
284
|
+
| ClinicalTrials | `search_clinical_trials` | 臨床試験検索 |
|
|
285
|
+
| ClinicalTrials | `clinical_trials_get_details` | 試験詳細取得 |
|
|
286
|
+
| PharmGKB | `PharmGKB_get_dosing_guidelines` | PGx 用量ガイドライン |
|
|
287
|
+
| PharmGKB | `PharmGKB_get_clinical_annotations` | 臨床アノテーション |
|
|
288
|
+
| CPIC | `CPIC_get_guidelines` | CPIC ガイドライン |
|
|
289
|
+
| DGIdb | `DGIdb_get_drug_gene_interactions` | 薬物-遺伝子相互作用 |
|
|
290
|
+
| PubMed | `PubMed_search_articles` | エビデンス検索 |
|
|
291
|
+
|
|
278
292
|
### 参照スキル
|
|
279
293
|
|
|
280
294
|
| スキル | 連携 |
|