# MASLDTriangulate-Kor (매슬드트라이앵귤레이트코어)

> ⚠️ **본 도구는 MASLD/MASH 인과추론 연구 가설 생성·문헌 갭 분석 목적의 연구용·교육용 도구입니다.
> 임상의사결정·환자 진료·약물 처방·예후 예측에 직접 사용해서는 안 되며, 모든 분석 결과는
> 추가 임상 검증이 필요합니다. 환자별 의사결정은 반드시 자격 있는 간 전문의(소화기내과)와
> 상담 후 결정해야 합니다.**

## 한 줄

MASLD 단계(steatosis·MASH·F2·F3·F4·lean MASLD) × 15+ outcome(LRC mortality·HCC·decompensation·
CV death·all-cause·CKD/ESKD·12 extra-hepatic cancer·T2DM 발생·sarcopenia·dementia) 격자에 대해
**5-design** (Observational(NHANES·UKB·KoNEHS·NHIS) · MR(PNPLA3·TM6SF2·HSD17B13·MBOAT7·GCKR·proteome) ·
RCT(MAESTRO-NASH·ESSENCE·SYNERGY-NASH interim) · ex vivo PCLS / DIO animal · within-subject lifestyle
crossover) effect 추정치를 통합하고 **concordance/discordance** 진단, **MASLD-mediated vs
metabolic-confounder-mediated 분리**, **PNPLA3/HSD17B13/TM6SF2 genotype-stratified treatment effect
가설**, **triangulation-targeted 후속 연구 design 8종**을 자동 생성하는 standalone Streamlit +
CLI 도구.

## 핵심 기능 (5)
1. **5-design effect ingest + MASLD-outcome 온톨로지**
   - 단계 6종 · biomarker (FIB-4·VCTE·MR-PDFF·histology) · 15+ outcome (12 extra-hepatic cancer
     포함) · 한국 lean MASLD subphenotype layer.
2. **5-design triangulation grid + MASLD vs metabolic confounder mediator 분리**
   - Multivariable MR (PNPLA3 + BMI + T2DM 동시 IV).
   - Mediation analysis (log-effect 기반 fraction 분해).
3. **Genotype-stratified treatment effect 가설**
   - PNPLA3·HSD17B13·TM6SF2 subgroup, 한국 allele frequency (PNPLA3 G ~0.30) 적용.
   - **TM6SF2 MASLD↑·CV↓ discordant 패턴 자동 flag.**
4. **Discordance bias direction 진단 + 8 triangulation-targeted 후속 가설**
   - Bias taxonomy 10종 (metabolic syndrome confounding · MR pleiotropy · canalization ·
     dose translation · external validity Korean lean MASLD · NIT detection bias 등).
   - 8 design: MVMR / PCLS genotyped / active comparator / RCT genotype subgroup /
     within-subject crossover / negative control / animal-human bridging / bariatric NE.
5. **KASL·AASLD/EASL·OpenClaw·MASLDStager 리포트 (Markdown·JSON, docx export 옵션)**

## 디렉토리

```
.
├── README.md
├── CHANGELOG.md
├── QA.md
├── requirements.txt
├── main.py            # CLI (stdlib only)
├── app.py             # Streamlit UI
├── triangulation/
│   ├── __init__.py
│   ├── ontology.py
│   ├── grid.py        # 5-design effect grid + concordance
│   ├── lawlor.py      # Lawlor 5-criterion
│   ├── mvmr.py        # multivariable MR (PNPLA3 + BMI + T2DM)
│   ├── mediation.py   # MASLD vs metabolic mediator 분리
│   ├── genotype.py    # PNPLA3/HSD17B13/TM6SF2 + Korean AF
│   ├── bias.py        # bias taxonomy 10종
│   ├── designs.py     # 8 design cards
│   └── report.py      # Markdown / JSON / docx export
└── data/
    ├── effects_sample.csv          # 5-design 큐레이션 (43 rows)
    ├── masld_stages.csv
    ├── outcome_ontology.csv        # 30 outcomes
    ├── mr_instruments.csv
    ├── allele_frequency_korean.csv
    └── README.md
```

## 빠른 사용

### CLI (stdlib only — pandas/streamlit 불필요)
```bash
python3 main.py --help
python3 main.py --data-test
python3 main.py --grid
python3 main.py --pair "MASH" "CV death"
python3 main.py --mediation "MASH" "CV death"
python3 main.py --genotype "PNPLA3" "resmetirom" "MASH"
python3 main.py --discordant --top 5
python3 main.py --korean
python3 main.py --designs
python3 main.py --taxonomy
python3 main.py --report out.json
python3 main.py --report-md out.md
```

### Streamlit
```bash
pip install -r requirements.txt
streamlit run app.py
```

## 제약 / 주의
- 외부 네트워크·유료 API 호출 0.
- main.py 는 **stdlib only** — pandas/streamlit/plotly 불필요.
- 모든 효과 추정치는 큐레이션된 정성치 (개별 study 정확치 ≠ 본 도구 입력값).
- MR 효과는 단위 (per allele·per SD log-liability) 혼재 — triangulation 진단 목적 정성 비교만.

## 참고
- Lawlor DA et al. Triangulation in aetiological epidemiology. IJE 2016.
- Burgess S, Thompson SG. Multivariable Mendelian randomization. AJE 2015.
- Sanderson E et al. MVMR sensitivity. IJE 2019.
- Sanyal AJ et al. NEJM 2021. Histologic disease predicts LRC outcomes.
- Mantovani A et al. Gut 2021/2022. MASLD ↔ CV/CKD/CRC meta-analyses.
- Vujkovic M et al. Nat Genet 2022. UKB+FinnGen MR.
- Bianco C et al. J Hepatol 2020. PNPLA3 HCC MR.
- Abul-Husn NS et al. NEJM 2018. HSD17B13 LoF protective.
- Harrison SA et al. NEJM 2024. MAESTRO-NASH (resmetirom).
- Eslam M et al. Lancet Gastro Hepatol 2020. Korean lean MASLD.
- KASL clinical practice guidelines for nonalcoholic fatty liver disease 2021.
- AASLD Practice Guidance on MASLD 2023 (Rinella).
- EASL-EASD-EASO Clinical Practice Guidelines on MASLD 2024.
