@nahisaho/satori 0.8.0 → 0.10.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.
Files changed (34) hide show
  1. package/README.md +138 -2
  2. package/package.json +1 -1
  3. package/src/.github/skills/scientific-admet-pharmacokinetics/SKILL.md +14 -0
  4. package/src/.github/skills/scientific-bioinformatics/SKILL.md +13 -0
  5. package/src/.github/skills/scientific-cheminformatics/SKILL.md +13 -0
  6. package/src/.github/skills/scientific-citation-checker/SKILL.md +12 -0
  7. package/src/.github/skills/scientific-clinical-decision-support/SKILL.md +14 -0
  8. package/src/.github/skills/scientific-deep-research/SKILL.md +15 -0
  9. package/src/.github/skills/scientific-disease-research/SKILL.md +14 -0
  10. package/src/.github/skills/scientific-drug-repurposing/SKILL.md +14 -0
  11. package/src/.github/skills/scientific-drug-target-profiling/SKILL.md +14 -0
  12. package/src/.github/skills/scientific-environmental-ecology/SKILL.md +295 -0
  13. package/src/.github/skills/scientific-epidemiology-public-health/SKILL.md +332 -0
  14. package/src/.github/skills/scientific-grant-writing/SKILL.md +12 -0
  15. package/src/.github/skills/scientific-graph-neural-networks/SKILL.md +12 -0
  16. package/src/.github/skills/scientific-immunoinformatics/SKILL.md +341 -0
  17. package/src/.github/skills/scientific-infectious-disease/SKILL.md +342 -0
  18. package/src/.github/skills/scientific-meta-analysis/SKILL.md +11 -0
  19. package/src/.github/skills/scientific-metabolomics/SKILL.md +13 -0
  20. package/src/.github/skills/scientific-microbiome-metagenomics/SKILL.md +349 -0
  21. package/src/.github/skills/scientific-multi-omics/SKILL.md +13 -0
  22. package/src/.github/skills/scientific-network-analysis/SKILL.md +13 -0
  23. package/src/.github/skills/scientific-pharmacovigilance/SKILL.md +15 -0
  24. package/src/.github/skills/scientific-population-genetics/SKILL.md +336 -0
  25. package/src/.github/skills/scientific-precision-oncology/SKILL.md +14 -0
  26. package/src/.github/skills/scientific-protein-design/SKILL.md +13 -0
  27. package/src/.github/skills/scientific-protein-structure-analysis/SKILL.md +13 -0
  28. package/src/.github/skills/scientific-sequence-analysis/SKILL.md +13 -0
  29. package/src/.github/skills/scientific-single-cell-genomics/SKILL.md +361 -0
  30. package/src/.github/skills/scientific-spatial-transcriptomics/SKILL.md +281 -0
  31. package/src/.github/skills/scientific-survival-clinical/SKILL.md +12 -0
  32. package/src/.github/skills/scientific-systems-biology/SKILL.md +310 -0
  33. package/src/.github/skills/scientific-text-mining-nlp/SKILL.md +358 -0
  34. package/src/.github/skills/scientific-variant-interpretation/SKILL.md +14 -0
@@ -0,0 +1,336 @@
1
+ ---
2
+ name: scientific-population-genetics
3
+ description: |
4
+ 集団遺伝学解析スキル。アレル頻度解析・Hardy-Weinberg 平衡検定・
5
+ 集団構造解析(PCA / ADMIXTURE)・Fst 分化指標・選択圧検出(iHS / XP-EHH)・
6
+ 連鎖不平衡(LD)解析・GWAS Catalog / gnomAD データ統合パイプライン。
7
+ ---
8
+
9
+ # Scientific Population Genetics
10
+
11
+ 集団遺伝学に特化した解析パイプラインを提供する。
12
+ アレル頻度、集団構造、遺伝的分化、自然選択シグナル、
13
+ 連鎖不平衡の解析を体系的に扱い、GWAS Catalog・gnomAD との統合を支援する。
14
+
15
+ ## When to Use
16
+
17
+ - アレル頻度分布や Hardy-Weinberg 平衡を検定するとき
18
+ - 集団構造(PCA / ADMIXTURE / STRUCTURE)を解析するとき
19
+ - 集団間の遺伝的分化(Fst)を評価するとき
20
+ - 自然選択シグナル(iHS / Tajima's D / XP-EHH)を検出するとき
21
+ - GWAS 関連バリアントの集団遺伝学的解釈を行うとき
22
+
23
+ ---
24
+
25
+ ## Quick Start
26
+
27
+ ## 1. QC・アレル頻度解析
28
+
29
+ ```python
30
+ import numpy as np
31
+ import pandas as pd
32
+
33
+ def genotype_qc(plink_prefix, mind=0.02, geno=0.02, maf=0.01,
34
+ hwe_p=1e-6):
35
+ """
36
+ ジェノタイプ QC パイプライン(PLINK 2)。
37
+
38
+ フィルタリング基準:
39
+ - --mind: 個体ミッシング率 ≤ mind
40
+ - --geno: SNP ミッシング率 ≤ geno
41
+ - --maf: Minor Allele Frequency ≥ maf
42
+ - --hwe: Hardy-Weinberg p ≥ hwe_p(コントロールのみ)
43
+
44
+ 追加 QC:
45
+ - 性別不一致チェック
46
+ - IBD 推定(近親者除外: π̂ > 0.25)
47
+ - PCA アウトライアー除外
48
+ """
49
+ import subprocess
50
+
51
+ # Step 1: ミッシング率フィルタ
52
+ cmd = (f"plink2 --bfile {plink_prefix} "
53
+ f"--mind {mind} --geno {geno} --maf {maf} "
54
+ f"--hwe {hwe_p} "
55
+ f"--make-bed --out {plink_prefix}_qc")
56
+ subprocess.run(cmd, shell=True, check=True)
57
+
58
+ # Step 2: IBD 推定(近親者検出)
59
+ cmd = (f"plink2 --bfile {plink_prefix}_qc "
60
+ f"--indep-pairwise 50 5 0.2 --out {plink_prefix}_prune")
61
+ subprocess.run(cmd, shell=True, check=True)
62
+
63
+ cmd = (f"plink2 --bfile {plink_prefix}_qc "
64
+ f"--extract {plink_prefix}_prune.prune.in "
65
+ f"--genome --out {plink_prefix}_ibd")
66
+ subprocess.run(cmd, shell=True, check=True)
67
+
68
+ return f"{plink_prefix}_qc"
69
+
70
+
71
+ def allele_frequency_stats(genotype_matrix, populations):
72
+ """
73
+ 集団別アレル頻度統計。
74
+
75
+ 算出指標:
76
+ - MAF: Minor Allele Frequency
77
+ - Het: Observed heterozygosity = n_het / n_total
78
+ - Expected Het (He): 2pq
79
+ - HWE: Hardy-Weinberg 平衡検定 (χ² test)
80
+ H₀: f(AA) = p², f(Aa) = 2pq, f(aa) = q²
81
+ """
82
+ from scipy.stats import chi2
83
+
84
+ results = []
85
+ for pop in populations["population"].unique():
86
+ pop_idx = populations[populations["population"] == pop].index
87
+ geno_pop = genotype_matrix.loc[pop_idx]
88
+
89
+ for snp in geno_pop.columns:
90
+ counts = geno_pop[snp].value_counts()
91
+ n = counts.sum()
92
+ n_0 = counts.get(0, 0) # AA
93
+ n_1 = counts.get(1, 0) # Aa
94
+ n_2 = counts.get(2, 0) # aa
95
+
96
+ p = (2 * n_0 + n_1) / (2 * n)
97
+ q = 1 - p
98
+ maf = min(p, q)
99
+
100
+ # HWE test
101
+ exp_0 = n * p**2
102
+ exp_1 = n * 2*p*q
103
+ exp_2 = n * q**2
104
+ if exp_0 > 0 and exp_1 > 0 and exp_2 > 0:
105
+ chi2_stat = ((n_0-exp_0)**2/exp_0 + (n_1-exp_1)**2/exp_1 +
106
+ (n_2-exp_2)**2/exp_2)
107
+ hwe_p = 1 - chi2.cdf(chi2_stat, df=1)
108
+ else:
109
+ hwe_p = 1.0
110
+
111
+ het_obs = n_1 / n
112
+ het_exp = 2 * p * q
113
+
114
+ results.append({
115
+ "snp": snp, "population": pop,
116
+ "MAF": round(maf, 4), "p": round(p, 4),
117
+ "Het_obs": round(het_obs, 4), "Het_exp": round(het_exp, 4),
118
+ "HWE_p": round(hwe_p, 6),
119
+ })
120
+
121
+ return pd.DataFrame(results)
122
+ ```
123
+
124
+ ## 2. 集団構造解析
125
+
126
+ ```python
127
+ def population_structure(plink_prefix, n_components=10, method="pca"):
128
+ """
129
+ 集団構造解析。
130
+
131
+ method:
132
+ - "pca": 主成分分析 — 集団間の遺伝的差異を 2D/3D で可視化
133
+ - "admixture": ADMIXTURE — 各個体の祖先集団比率を推定
134
+ K=2〜10 を試行し、CV error 最小の K を選択
135
+
136
+ PCA on genotypes:
137
+ X を (n_samples × n_snps) ジェノタイプ行列として
138
+ 共分散行列 C = XᵀX / n_snps の固有値分解
139
+ """
140
+ import subprocess
141
+
142
+ if method == "pca":
143
+ cmd = (f"plink2 --bfile {plink_prefix} "
144
+ f"--pca {n_components} --out {plink_prefix}_pca")
145
+ subprocess.run(cmd, shell=True, check=True)
146
+
147
+ eigenvec = pd.read_csv(f"{plink_prefix}_pca.eigenvec", sep="\t")
148
+ eigenval = pd.read_csv(f"{plink_prefix}_pca.eigenval", header=None)
149
+ var_explained = eigenval[0] / eigenval[0].sum()
150
+
151
+ print(f" PCA: PC1={var_explained[0]:.3f}, PC2={var_explained[1]:.3f}")
152
+ return eigenvec, var_explained
153
+
154
+ elif method == "admixture":
155
+ cv_errors = {}
156
+ for K in range(2, 11):
157
+ cmd = f"admixture --cv {plink_prefix}.bed {K}"
158
+ result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
159
+ # CV error 抽出
160
+ for line in result.stdout.split("\n"):
161
+ if "CV error" in line:
162
+ cv_errors[K] = float(line.split(": ")[1])
163
+
164
+ best_K = min(cv_errors, key=cv_errors.get)
165
+ Q = pd.read_csv(f"{plink_prefix}.{best_K}.Q", sep=" ", header=None)
166
+
167
+ print(f" ADMIXTURE: best K={best_K} (CV error={cv_errors[best_K]:.4f})")
168
+ return Q, cv_errors, best_K
169
+ ```
170
+
171
+ ## 3. 遺伝的分化(Fst)
172
+
173
+ ```python
174
+ def calculate_fst(genotype_matrix, populations, method="weir_cockerham"):
175
+ """
176
+ 集団間遺伝的分化指標 Fst 算出。
177
+
178
+ Weir-Cockerham (1984) 推定量:
179
+ F_ST = σ²_a / (σ²_a + σ²_b + σ²_w)
180
+ σ²_a: 集団間分散
181
+ σ²_b: 集団内個体間分散
182
+ σ²_w: 個体内(アレル間)分散
183
+
184
+ 解釈:
185
+ Fst = 0: 分化なし(パンミクシア)
186
+ 0 < Fst < 0.05: 低分化
187
+ 0.05 ≤ Fst < 0.15: 中程度の分化
188
+ 0.15 ≤ Fst < 0.25: 大きな分化
189
+ Fst ≥ 0.25: 非常に大きな分化
190
+
191
+ genome-wide Fst: 全 SNP の加重平均
192
+ per-SNP Fst: 局所的適応シグナルの検出
193
+ """
194
+ pop_labels = populations["population"]
195
+ unique_pops = pop_labels.unique()
196
+
197
+ fst_per_snp = []
198
+ for snp in genotype_matrix.columns:
199
+ # 集団別アレル頻度
200
+ pop_freqs = {}
201
+ pop_sizes = {}
202
+ for pop in unique_pops:
203
+ idx = pop_labels[pop_labels == pop].index
204
+ geno = genotype_matrix.loc[idx, snp].dropna()
205
+ p = (2 * (geno == 0).sum() + (geno == 1).sum()) / (2 * len(geno))
206
+ pop_freqs[pop] = p
207
+ pop_sizes[pop] = len(geno)
208
+
209
+ # Weir-Cockerham Fst
210
+ n_pops = len(unique_pops)
211
+ n_total = sum(pop_sizes.values())
212
+ p_bar = sum(pop_freqs[p] * pop_sizes[p] for p in unique_pops) / n_total
213
+ n_bar = n_total / n_pops
214
+
215
+ MSP = sum(pop_sizes[p] * (pop_freqs[p] - p_bar)**2
216
+ for p in unique_pops) / (n_pops - 1)
217
+ MSG = sum(pop_sizes[p] * pop_freqs[p] * (1 - pop_freqs[p])
218
+ for p in unique_pops) / (n_total - n_pops)
219
+
220
+ nc = (n_total - sum(n**2 for n in pop_sizes.values()) / n_total) / (n_pops - 1)
221
+
222
+ if (MSP + (nc - 1) * MSG) > 0:
223
+ fst = (MSP - MSG) / (MSP + (nc - 1) * MSG)
224
+ else:
225
+ fst = 0
226
+
227
+ fst_per_snp.append({"snp": snp, "Fst": max(fst, 0), "p_bar": p_bar})
228
+
229
+ fst_df = pd.DataFrame(fst_per_snp)
230
+ genome_fst = fst_df["Fst"].mean()
231
+
232
+ print(f" Fst: genome-wide={genome_fst:.4f}, "
233
+ f"max per-SNP={fst_df['Fst'].max():.4f}")
234
+ return fst_df, genome_fst
235
+ ```
236
+
237
+ ## 4. 自然選択シグナル検出
238
+
239
+ ```python
240
+ def selection_scan(haplotype_matrix, positions, method="ihs"):
241
+ """
242
+ 自然選択シグナルの検出。
243
+
244
+ method:
245
+ - "ihs": Integrated Haplotype Score — ローカル正の選択
246
+ |iHS| > 2: 選択シグナル候補
247
+ - "tajima_d": Tajima's D — 中立性検定
248
+ D > 0: バランス選択 or 集団縮小
249
+ D < 0: 正の選択 or 集団拡大
250
+ D ≈ 0: 中立進化
251
+ - "xpehh": Cross-Population EHH — 集団間正の選択
252
+
253
+ iHS:
254
+ 各 SNP について、派生アレル (derived) と祖先アレル (ancestral) の
255
+ Extended Haplotype Homozygosity (EHH) を比較。
256
+ iHS = ln(iHH_A / iHH_D) → 標準化
257
+ """
258
+ if method == "tajima_d":
259
+ # スライディングウィンドウ Tajima's D
260
+ from allel import tajima_d
261
+ import allel
262
+
263
+ D_values = []
264
+ window_size = 50000
265
+ step = 10000
266
+
267
+ for start in range(0, positions[-1], step):
268
+ end = start + window_size
269
+ mask = (positions >= start) & (positions < end)
270
+ if mask.sum() > 5:
271
+ ac = allel.AlleleCountsArray(
272
+ haplotype_matrix[:, mask].sum(axis=0).reshape(-1, 1))
273
+ D = tajima_d(ac)
274
+ D_values.append({"start": start, "end": end, "D": D,
275
+ "n_snps": mask.sum()})
276
+
277
+ df = pd.DataFrame(D_values)
278
+ print(f" Tajima's D: mean={df['D'].mean():.3f}, "
279
+ f"range=[{df['D'].min():.3f}, {df['D'].max():.3f}]")
280
+ return df
281
+
282
+ elif method == "ihs":
283
+ import allel
284
+ ihs = allel.ihs(haplotype_matrix, positions)
285
+ # 標準化
286
+ ihs_std = (ihs - np.nanmean(ihs)) / np.nanstd(ihs)
287
+
288
+ n_sig = np.sum(np.abs(ihs_std) > 2)
289
+ print(f" iHS: {n_sig} candidate regions (|iHS|>2)")
290
+ return ihs_std
291
+ ```
292
+
293
+ ## References
294
+
295
+ ### Output Files
296
+
297
+ | ファイル | 形式 |
298
+ |---|---|
299
+ | `results/allele_frequencies.csv` | CSV |
300
+ | `results/pca_eigenvec.csv` | CSV |
301
+ | `results/admixture_Q.csv` | CSV |
302
+ | `results/fst_per_snp.csv` | CSV |
303
+ | `results/selection_scan.csv` | CSV |
304
+ | `figures/pca_populations.png` | PNG |
305
+ | `figures/admixture_barplot.png` | PNG |
306
+ | `figures/manhattan_fst.png` | PNG |
307
+
308
+ ### 利用可能ツール
309
+
310
+ > [ToolUniverse](https://github.com/mims-harvard/ToolUniverse) SMCP 経由で利用可能な外部ツール。
311
+
312
+ | カテゴリ | 主要ツール | 用途 |
313
+ |---|---|---|
314
+ | gnomAD | `gnomad_get_variant` | バリアント集団頻度 |
315
+ | gnomAD | `gnomad_get_gene_constraints` | 遺伝子制約指標 |
316
+ | gnomAD | `gnomad_get_region` | 領域別バリアント |
317
+ | gnomAD | `gnomad_search_variants` | バリアント検索 |
318
+ | GWAS | `GWAS_search_associations_by_gene` | 遺伝子別 GWAS 関連 |
319
+ | GWAS | `gwas_search_studies` | GWAS 研究検索 |
320
+ | GWAS | `gwas_get_variants_for_trait` | 形質別バリアント |
321
+ | GWAS | `gwas_get_associations_for_snp` | SNP 別関連 |
322
+ | GWAS | `gwas_get_snps_for_gene` | 遺伝子近傍 SNP |
323
+
324
+ ### 参照スキル
325
+
326
+ | スキル | 連携内容 |
327
+ |---|---|
328
+ | [scientific-variant-interpretation](../scientific-variant-interpretation/SKILL.md) | バリアント臨床解釈 |
329
+ | [scientific-bioinformatics](../scientific-bioinformatics/SKILL.md) | ゲノムアノテーション |
330
+ | [scientific-disease-research](../scientific-disease-research/SKILL.md) | 疾患-遺伝子関連 |
331
+ | [scientific-statistical-testing](../scientific-statistical-testing/SKILL.md) | 統計検定 |
332
+ | [scientific-pca-tsne](../scientific-pca-tsne/SKILL.md) | 次元削減 |
333
+
334
+ #### 依存パッケージ
335
+
336
+ - scikit-allel, plink2, admixture, pandas, numpy, scipy
@@ -397,6 +397,20 @@ def generate_mtb_report(patient_id, variants, civic_data, oncokb_data,
397
397
  | `results/mtb_report.md` | MTB レポート(Markdown) | レポート生成時 |
398
398
  | `results/variant_actionability.json` | バリアント臨床的意義(JSON) | アノテーション完了時 |
399
399
 
400
+ ### 利用可能ツール
401
+
402
+ > [ToolUniverse](https://github.com/mims-harvard/ToolUniverse) SMCP 経由で利用可能な外部ツール。
403
+
404
+ | カテゴリ | 主要ツール | 用途 |
405
+ |---|---|---|
406
+ | OncoKB | `OncoKB_annotate_variant` | 体細胞変異の臨床的アノテーション |
407
+ | OncoKB | `OncoKB_get_cancer_genes` | がん遺伝子リスト取得 |
408
+ | CIViC | `civic_search_evidence_items` | 臨床エビデンス検索 |
409
+ | CIViC | `civic_get_variant` | バリアント臨床解釈 |
410
+ | COSMIC | `COSMIC_get_mutations_by_gene` | 体細胞変異頻度データ |
411
+ | GDC | `GDC_get_mutation_frequency` | TCGA 変異頻度 |
412
+ | ClinicalTrials | `search_clinical_trials` | 腫瘍学臨床試験マッチング |
413
+
400
414
  ### 参照スキル
401
415
 
402
416
  | スキル | 連携 |
@@ -291,6 +291,19 @@ EXPRESSION_SYSTEMS = {
291
291
  | `results/design_candidates.json` | 設計候補データ(JSON) | スクリーニング完了時 |
292
292
  | `results/esm_scores.json` | ESM スコアデータ(JSON) | 変異スキャン完了時 |
293
293
 
294
+ ### 利用可能ツール
295
+
296
+ > [ToolUniverse](https://github.com/mims-harvard/ToolUniverse) SMCP 経由で利用可能な外部ツール。
297
+
298
+ | カテゴリ | 主要ツール | 用途 |
299
+ |---|---|---|
300
+ | UniProt | `UniProt_get_entry_by_accession` | タンパク質エントリ取得 |
301
+ | UniProt | `UniProt_get_sequence_by_accession` | アミノ酸配列取得 |
302
+ | InterPro | `InterPro_get_protein_domains` | ドメインアノテーション |
303
+ | Proteins API | `proteins_api_get_features` | タンパク質特徴情報 |
304
+ | Proteins API | `proteins_api_get_variants` | 既知変異体情報 |
305
+ | AlphaMissense | `AlphaMissense_get_residue_scores` | 残基レベル耐性予測 |
306
+
294
307
  ### 参照スキル
295
308
 
296
309
  | スキル | 連携 |
@@ -309,6 +309,19 @@ def detect_binding_sites(pdb_id):
309
309
  | `results/structure_analysis.json` | 構造データ(JSON) | 品質評価完了時 |
310
310
  | `results/binding_sites.json` | 結合部位データ(JSON) | ポケット解析完了時 |
311
311
 
312
+ ### 利用可能ツール
313
+
314
+ > [ToolUniverse](https://github.com/mims-harvard/ToolUniverse) SMCP 経由で利用可能な外部ツール。
315
+
316
+ | カテゴリ | 主要ツール | 用途 |
317
+ |---|---|---|
318
+ | UniProt | `UniProt_get_entry_by_accession` | タンパク質エントリ取得 |
319
+ | InterPro | `InterPro_get_protein_domains` | ドメインアノテーション |
320
+ | InterPro | `InterProScan_scan_sequence` | 配列ドメインスキャン |
321
+ | BindingDB | `BindingDB_get_ligands_by_uniprot` | リガンド結合データ |
322
+ | Proteins API | `proteins_api_get_features` | タンパク質特徴情報 |
323
+ | AlphaMissense | `AlphaMissense_get_protein_scores` | 残基レベル病原性予測 |
324
+
312
325
  ### 参照スキル
313
326
 
314
327
  | スキル | 連携 |
@@ -384,6 +384,19 @@ def protein_properties(protein_seq):
384
384
  | `figures/phylogenetic_tree.png` | PNG |
385
385
  | `figures/hydrophobicity_profile.png` | PNG |
386
386
 
387
+ ### 利用可能ツール
388
+
389
+ > [ToolUniverse](https://github.com/mims-harvard/ToolUniverse) SMCP 経由で利用可能な外部ツール。
390
+
391
+ | カテゴリ | 主要ツール | 用途 |
392
+ |---|---|---|
393
+ | BLAST | `BLAST_protein_search` | タンパク質相同性検索 |
394
+ | BLAST | `BLAST_nucleotide_search` | 核酸相同性検索 |
395
+ | UniProt | `UniProt_get_sequence_by_accession` | アミノ酸配列取得 |
396
+ | NCBI | `NCBI_get_sequence` | ヌクレオチド配列取得 |
397
+ | InterPro | `InterProScan_scan_sequence` | 配列ドメインスキャン |
398
+ | InterPro | `InterPro_get_protein_domains` | ドメインアノテーション |
399
+
387
400
  #### 参照実験
388
401
 
389
402
  - **Exp-09**: コドン使用頻度、ペアワイズアラインメント、系統解析、ORF 探索、CpG 島検出