# labastar/phers architecture

> Architecture diagram of the GitHub repository labastar/phers, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/labastar/phers
- Repository: https://github.com/labastar/phers

## Overview

PheRS is an R-based phenotyping tool: it turns cohort ICD-9 diagnoses into disease phenotype scores and offers a separate grid-plotting script for inspecting a selected disease across individuals. The README also identifies mapping, disease-label, and weight data files, but no source excerpts show how the scripts load or combine them, so those relationships are omitted. The documented workflow and outputs are shown; implementation details beyond the README remain unverified.

Main entry points: [`PheRS code.R`](https://github.com/labastar/phers/blob/master/PheRS%20code.R) (PheRS generator), [`PheRS_Grid.R`](https://github.com/labastar/phers/blob/master/PheRS_Grid.R) (Disease grid plot), [`icd9s_sample_data.txt`](https://github.com/labastar/phers/blob/master/icd9s_sample_data.txt) (Sample ICD-9 data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_phenotyping["Phenotyping"]
  node_scorer["PheRS generator<br/>[PheRS code.R]"]
  node_phenotype["PLINK phenotype"]
  node_grid["Disease grid plot<br/>[PheRS_Grid.R]"]
end

subgraph group_resources["Data resources"]
  node_sample["Sample ICD-9 data"]
  node_disease_map["Disease phecodes"]
  node_code_map["ICD-9 phecode map"]
  node_phecode_labels["Phecode strings"]
  node_weights["Discovery weights"]
end

node_cohort["ICD-9 cohort"]
node_plot["Heatmap plot"]

node_cohort -->|"provides diagnoses"| node_scorer
node_scorer -->|"generates"| node_phenotype
node_cohort -->|"provides diagnoses"| node_grid
node_grid -->|"generates"| node_plot
node_sample -->|"sample input"| node_scorer
node_sample -->|"sample input"| node_grid

click node_scorer "https://github.com/labastar/phers/blob/master/PheRS%20code.R"
click node_grid "https://github.com/labastar/phers/blob/master/PheRS_Grid.R"
click node_sample "https://github.com/labastar/phers/blob/master/icd9s_sample_data.txt"
click node_disease_map "https://github.com/labastar/phers/blob/master/disease_to_phecodes.txt"
click node_code_map "https://github.com/labastar/phers/blob/master/icd9_to_phecode.txt"
click node_phecode_labels "https://github.com/labastar/phers/blob/master/phecode_strings.txt"
click node_weights "https://github.com/labastar/phers/blob/master/weights_VUMC_discovery.txt"

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_scorer,node_phenotype,node_grid toneBlue
class node_sample,node_disease_map,node_code_map,node_phecode_labels,node_weights toneAmber
class node_cohort,node_plot toneIndigo
```

## Components

### Phenotyping

- [PheRS generator](https://github.com/labastar/phers/blob/master/PheRS%20code.R): `PheRS code.R`
- **PLINK phenotype**
- [Disease grid plot](https://github.com/labastar/phers/blob/master/PheRS_Grid.R): `PheRS_Grid.R`

### Data resources

- [Sample ICD-9 data](https://github.com/labastar/phers/blob/master/icd9s_sample_data.txt): `icd9s_sample_data.txt`
- [Disease phecodes](https://github.com/labastar/phers/blob/master/disease_to_phecodes.txt): `disease_to_phecodes.txt`
- [ICD-9 phecode map](https://github.com/labastar/phers/blob/master/icd9_to_phecode.txt): `icd9_to_phecode.txt`
- [Phecode strings](https://github.com/labastar/phers/blob/master/phecode_strings.txt): `phecode_strings.txt`
- [Discovery weights](https://github.com/labastar/phers/blob/master/weights_VUMC_discovery.txt): `weights_VUMC_discovery.txt`

### Other components

- **ICD-9 cohort**
- **Heatmap plot**

## Connections

- ICD-9 cohort → PheRS generator: provides diagnoses (evidence: `README.md`)
- PheRS generator → PLINK phenotype: generates (evidence: `README.md`)
- ICD-9 cohort → Disease grid plot: provides diagnoses (evidence: `README.md`)
- Disease grid plot → Heatmap plot: generates (evidence: `README.md`)
- Sample ICD-9 data → PheRS generator: sample input (evidence: `README.md`)
- Sample ICD-9 data → Disease grid plot: sample input (evidence: `README.md`)
