# hide-in-lab/multi architecture

> Architecture diagram of the GitHub repository hide-in-lab/multi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hide-in-lab/multi
- Repository: https://github.com/hide-in-lab/multi

## Overview

MULTI is an R package for multi-tissue Mendelian-randomization analysis. Users supply per-tissue IV-to-exposure and IV-to-outcome estimates, their standard errors, and LD matrices. The MULTI entry point estimates effects tissue by tissue, compares them with Hellinger distances, and identifies supportive tissues under a cutoff. Users then combine eligible IVs, re-estimate the LD matrix, and call MULTI_single for the final effect. README documents these stages; the source excerpt confirms the native estimation and distance calculations, but omits the remainder of MULTI’s selection logic.

Main entry points: [`src/MULTI.cpp`](https://github.com/hide-in-lab/multi/blob/main/src/MULTI.cpp) (MULTI Workflow), [`R/RcppExports.R`](https://github.com/hide-in-lab/multi/blob/main/R/RcppExports.R) (R API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["R Interface"]
  node_r_api["R API<br/>[RcppExports.R]"]
end

subgraph group_analysis["MULTI Analysis"]
  node_multi["MULTI Workflow<br/>[MULTI.cpp]"]
  node_single_fit["Per-tissue VEM<br/>[MULTI.cpp]"]
  node_distance["Hellinger Distance<br/>[MULTI.cpp]"]
  node_selection["Tissue Selection<br/>[MULTI.cpp]"]
  node_similarity_result["Similarity Results"]
end

subgraph group_final["Final Estimate"]
  node_iv_pool["Expanded IV Pool"]
  node_final_fit["Final VEM Fit<br/>[MULTI.cpp]"]
  node_effect_result["Causal Effect"]
end

node_researcher(("Researcher"))
node_tissue_data["Tissue Inputs"]

node_researcher -->|"calls"| node_r_api
node_researcher -->|"prepares"| node_tissue_data
node_tissue_data -->|"supplies"| node_multi
node_r_api -->|"dispatches"| node_multi
node_multi -->|"fits tissues"| node_single_fit
node_multi -->|"compares effects"| node_distance
node_multi -->|"applies cutoff"| node_selection
node_distance -->|"provides distances"| node_selection
node_selection -->|"returns selection"| node_similarity_result
node_similarity_result -->|"reports"| node_researcher
node_researcher -->|"combines IVs"| node_iv_pool
node_iv_pool -->|"supplies data"| node_final_fit
node_researcher -->|"calls single fit"| node_r_api
node_r_api -->|"dispatches"| node_final_fit
node_final_fit -->|"returns estimate"| node_effect_result
node_effect_result -->|"reports"| node_researcher

click node_r_api "https://github.com/hide-in-lab/multi/blob/main/R/RcppExports.R"
click node_multi "https://github.com/hide-in-lab/multi/blob/main/src/MULTI.cpp"
click node_single_fit "https://github.com/hide-in-lab/multi/blob/main/src/MULTI.cpp"
click node_distance "https://github.com/hide-in-lab/multi/blob/main/src/MULTI.cpp"
click node_selection "https://github.com/hide-in-lab/multi/blob/main/src/MULTI.cpp"
click node_final_fit "https://github.com/hide-in-lab/multi/blob/main/src/MULTI.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_r_api toneBlue
class node_multi,node_single_fit,node_distance,node_selection,node_similarity_result toneAmber
class node_iv_pool,node_final_fit,node_effect_result toneMint
class node_researcher,node_tissue_data toneIndigo
```

## Components

### R Interface

- [R API](https://github.com/hide-in-lab/multi/blob/main/R/RcppExports.R): `R/RcppExports.R`

### MULTI Analysis

- [MULTI Workflow](https://github.com/hide-in-lab/multi/blob/main/src/MULTI.cpp): `src/MULTI.cpp`
- [Per-tissue VEM](https://github.com/hide-in-lab/multi/blob/main/src/MULTI.cpp): `src/MULTI.cpp`
- [Hellinger Distance](https://github.com/hide-in-lab/multi/blob/main/src/MULTI.cpp): `src/MULTI.cpp`
- [Tissue Selection](https://github.com/hide-in-lab/multi/blob/main/src/MULTI.cpp): `src/MULTI.cpp`
- **Similarity Results**

### Final Estimate

- **Expanded IV Pool**
- [Final VEM Fit](https://github.com/hide-in-lab/multi/blob/main/src/MULTI.cpp): `src/MULTI.cpp`
- **Causal Effect**

### Other components

- **Researcher**
- **Tissue Inputs**

## Connections

- Researcher → R API: calls
- Researcher → Tissue Inputs: prepares
- Tissue Inputs → MULTI Workflow: supplies
- R API → MULTI Workflow: dispatches
- MULTI Workflow → Per-tissue VEM: fits tissues
- MULTI Workflow → Hellinger Distance: compares effects
- MULTI Workflow → Tissue Selection: applies cutoff
- Hellinger Distance → Tissue Selection: provides distances
- Tissue Selection → Similarity Results: returns selection
- Similarity Results → Researcher: reports
- Researcher → Expanded IV Pool: combines IVs
- Expanded IV Pool → Final VEM Fit: supplies data
- Researcher → R API: calls single fit
- R API → Final VEM Fit: dispatches
- Final VEM Fit → Causal Effect: returns estimate
- Causal Effect → Researcher: reports
