# kathoffman/steroids-trial-emulation architecture

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

- Interactive diagram: https://gitdiagram.com/kathoffman/steroids-trial-emulation
- Repository: https://github.com/kathoffman/steroids-trial-emulation

## Overview

This repository is a tutorial workflow for emulating a target trial and presenting its results. An analyst runs the R analysis with simulated or demo data and the documented lmtp package; results can then be cleaned and visualized. The README documents these roles, but no source excerpts were available, so the graph omits unverified implementation details and input links, especially for the timeline figure.

Main entry points: [`code/analysis.R`](https://github.com/kathoffman/steroids-trial-emulation/blob/main/code/analysis.R) (Target trial analysis), [`code/report_results.R`](https://github.com/kathoffman/steroids-trial-emulation/blob/main/code/report_results.R) (Clean analysis output), [`code/forest_plot_viz.R`](https://github.com/kathoffman/steroids-trial-emulation/blob/main/code/forest_plot_viz.R) (Forest plot), [`code/trt_timeline_viz.R`](https://github.com/kathoffman/steroids-trial-emulation/blob/main/code/trt_timeline_viz.R) (Treatment timeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Trial analysis"]
  node_analysis_script["Target trial analysis<br/>[analysis.R]"]
  node_lmtp["lmtp package"]
  node_censoring_prep["Censoring adjustment<br/>[fix_cens.R]"]
end

subgraph group_reporting["Results and figures"]
  node_report["Clean analysis output<br/>[report_results.R]"]
  node_forest_plot["Forest plot<br/>[forest_plot_viz.R]"]
  node_timeline_plot["Treatment timeline<br/>[trt_timeline_viz.R]"]
end

subgraph group_data["Analysis data"]
  node_demo_data[("Demo analysis data<br/>[dat_demo.rds]")]
  node_timeline_data[("Treatment timeline data")]
end

node_analyst(("Analyst"))

node_analyst -->|"runs"| node_analysis_script
node_analysis_script -->|"uses"| node_lmtp
node_analyst -->|"uses"| node_demo_data
node_report -->|"cleans output"| node_analysis_script
node_analyst -->|"creates figure"| node_forest_plot
node_analyst -->|"creates figure"| node_timeline_plot

click node_analysis_script "https://github.com/kathoffman/steroids-trial-emulation/blob/main/code/analysis.R"
click node_censoring_prep "https://github.com/kathoffman/steroids-trial-emulation/blob/main/code/fix_cens.R"
click node_demo_data "https://github.com/kathoffman/steroids-trial-emulation/blob/main/data/dat_demo.rds"
click node_timeline_data "https://github.com/kathoffman/steroids-trial-emulation/blob/main/data/dat_trt_timeline.csv"
click node_report "https://github.com/kathoffman/steroids-trial-emulation/blob/main/code/report_results.R"
click node_forest_plot "https://github.com/kathoffman/steroids-trial-emulation/blob/main/code/forest_plot_viz.R"
click node_timeline_plot "https://github.com/kathoffman/steroids-trial-emulation/blob/main/code/trt_timeline_viz.R"

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_analysis_script,node_lmtp,node_censoring_prep toneBlue
class node_report,node_forest_plot,node_timeline_plot toneAmber
class node_demo_data,node_timeline_data toneMint
class node_analyst toneIndigo
```

## Components

### Trial analysis

- [Target trial analysis](https://github.com/kathoffman/steroids-trial-emulation/blob/main/code/analysis.R): `code/analysis.R`
- **lmtp package**
- [Censoring adjustment](https://github.com/kathoffman/steroids-trial-emulation/blob/main/code/fix_cens.R): `code/fix_cens.R`

### Results and figures

- [Clean analysis output](https://github.com/kathoffman/steroids-trial-emulation/blob/main/code/report_results.R): `code/report_results.R`
- [Forest plot](https://github.com/kathoffman/steroids-trial-emulation/blob/main/code/forest_plot_viz.R): `code/forest_plot_viz.R`
- [Treatment timeline](https://github.com/kathoffman/steroids-trial-emulation/blob/main/code/trt_timeline_viz.R): `code/trt_timeline_viz.R`

### Analysis data

- [Demo analysis data](https://github.com/kathoffman/steroids-trial-emulation/blob/main/data/dat_demo.rds): `data/dat_demo.rds`
- [Treatment timeline data](https://github.com/kathoffman/steroids-trial-emulation/blob/main/data/dat_trt_timeline.csv): `data/dat_trt_timeline.csv`

### Other components

- **Analyst**

## Connections

- Analyst → Target trial analysis: runs (evidence: `README.md`)
- Target trial analysis → lmtp package: uses (evidence: `README.md`)
- Analyst → Demo analysis data: uses (evidence: `README.md`)
- Clean analysis output → Target trial analysis: cleans output (evidence: `README.md`)
- Analyst → Forest plot: creates figure (evidence: `README.md`)
- Analyst → Treatment timeline: creates figure (evidence: `README.md`)
