rust版本孟德尔随机化工具开发

最后发布时间 : 2026-08-24 18:02:40 浏览量 :

不是。要看你设计这个 gwas-mr 命令时,参数代表什么

如果按照我上一条建议的设计:

gwas-mr \
    --exposure microbiome.tsv.gz \
    --outcome disease.tsv.gz \
    --method ivw,egger,weighted-median \
    --clump-r2 0.001 \
    --clump-kb 10000

这里更合理的含义是:

  • --exposure原始/较完整的 exposure GWAS summary statistics
  • --outcome原始/较完整的 outcome GWAS summary statistics
  • --clump-r2--clump-kb:告诉程序如何从 exposure 中筛选独立工具变量

也就是说,不是要求用户提前把工具变量全部筛好


整个过程应该是

              exposure GWAS
                    │
                    ↓
          P < threshold 筛选 SNP
                    │
                    ↓
              LD clumping
                    │
                    ↓
          ┌─────────────────┐
          │ Instrument SNPs │
          └─────────────────┘
                    │
             ┌──────┴──────┐
             ↓             ↓
        exposure βX     outcome βY
             │             │
             └──────┬──────┘
                    ↓
              harmonization
                    ↓
                  MR

所以:

--exposure

不是“已经筛好的工具变量”,而应该是:

候选工具变量所在的 exposure GWAS summary statistics。

程序自己根据:

--p-threshold 5e-8
--clump-r2 0.001
--clump-kb 10000

筛选。


--outcome 则完全不同

Outcome 通常不需要先筛选成显著 SNP

例如你研究:

Bacteroides → 心肌梗死

你从 microbiome GWAS 中筛选:

SNP1
SNP2
SNP3
...

作为工具变量。

然后去 MI GWAS 中提取这些 SNP

             Microbiome GWAS
                    │
                    ↓
              筛选工具变量
                    │
              SNP1 SNP2 SNP3
                    │
                    ↓
             MI GWAS 中找
             SNP1 SNP2 SNP3
                    │
                    ↓
                  βY

因此 outcome GWAS 不应该做:

P < 5e-8

这样的筛选。

因为你关心的是:

这些 SNP 对 outcome 的效应是多少?

即使:

SNP1 → MI
P = 0.4

也完全可以使用。

实际上,如果 outcome SNP 必须自己也满足 P < 5e-8,会严重改变 MR 的设计。


所以一个更合理的 CLI 设计

我会把命令设计成:

gwas-mr \
    --exposure microbiome.tsv.gz \
    --outcome disease.tsv.gz \
    --exposure-p 5e-8 \
    --clump-r2 0.001 \
    --clump-kb 10000 \
    --method ivw,egger,weighted-median

程序内部:

exposure.tsv
     │
     ├── P < 5e-8
     │
     ↓
候选 SNP
     │
     ├── LD clumping
     │
     ↓
独立 instruments
     │
     ├───────────────────┐
     ↓                   ↓
exposure βX          outcome βY
                         ↑
                         │
                  outcome.tsv
                         │
                         ↓
                  按 SNP 提取
                         │
                         ↓
                  harmonization
                         │
                         ↓
                        MR

甚至可以进一步把 CLI 拆开

如果你是在设计 Rust GWAS 工具,我反而建议不要把所有东西硬塞进 gwas-mr

# 第一步:筛选 exposure SNP
gwas extract \
    --input microbiome.tsv.gz \
    --p 5e-8 \
    --output instruments.tsv

# 第二步:LD clumping
gwas clump \
    --input instruments.tsv \
    --reference 1000G_EUR \
    --r2 0.001 \
    --kb 10000 \
    --output instruments.clumped.tsv

# 第三步:从 outcome 提取相同 SNP
gwas extract-snps \
    --input disease.tsv.gz \
    --snps instruments.clumped.tsv \
    --output outcome.snps.tsv

# 第四步:MR
gwas mr \
    --exposure instruments.clumped.tsv \
    --outcome outcome.snps.tsv \
    --method ivw,egger,weighted-median

这样设计的好处是每一步的输入/输出都明确,也特别适合你之前设计的 biox-core / biox-tsv / biox-vcf 这种模块化 Rust 架构。