# runchenwang-dev/enrichgt architecture

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

- Interactive diagram: https://gitdiagram.com/runchenwang-dev/enrichgt
- Repository: https://github.com/runchenwang-dev/enrichgt

## Overview

EnrichGT is an experimental R package for gene set enrichment-style analysis. Architecturally, it is a single-package workflow centered on transforming gene inputs into enriched biological interpretations, with several downstream branches for visualization, reclustering, and inference.

The main inputs are two gene representations: a plain gene list and a weighted gene list. Those feed two separate analysis entry points: `egt_enrichment_analysis` for standard enrichment and `egt_gsea_analysis` for weighted/GSEA-style analysis.

A separate database layer, exposed through `database_*` functions, provides the pathway or gene-set reference data used by both analysis paths. This is the package’s main data dependency boundary: analysis functions consume the databases rather than embedding pathway knowledge directly.

Both analysis entry points converge on a common enriched-result output. That shared result object is the key handoff to the rest of the package, which means the architecture is organized around one canonical analysis result and multiple consumers.

Visualization is a distinct downstream subsystem. `egt_plot_results` is used for enrichment outputs, while `egt_plot_gsea` is dedicated to GSEA outputs. These functions sit at the presentation boundary and do not appear to alter the analysis data model.

There is also a reclustering-oriented branch, `egt_recluster_analysis`, which takes the enriched result and reorganizes it into gene clusters or modules. This branch produces two notable outputs: a “pretty table” for human review and an “AI annotation” layer for higher-level interpretation.

The reclustering branch also feeds back into visualization, since clusters/modules can be plotted through the same result-plotting path. In architecture terms, this is a secondary interpretation layer built on top of the core enrichment result.

A further downstream capability is pathway activity and transcription-factor inference via `egt_infer`. The README indicates this consumes gene modules rather than the raw enriched result, so it appears to depend on the reclustering output as an intermediate abstraction.

Overall, the data flow is: genes or weighted genes in, pathway databases in, enrichment/GSEA out, then optional branches for plotting, reclustering, annotation, and inference. The package is therefore more of an analysis pipeline than a collection of unrelated utilities.

The package is explicitly positioned as exploratory and not a replacement for established tools like `clusterProfiler` or Metascape. That matters architecturally because it suggests the package favors proof-of-concept analysis flow and interpretation features over a heavily validated production pipeline.

Distribution-wise, this is a standard R package installed via `pak`, with documentation hosted on a GitHub Pages site and source code on GitHub. No other runtime, backend service, or infrastructure is indicated in the README.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g1["Inputs & data"]
  node_n2["Gene list<br/>input"]
  node_n3["Weighted genes<br/>input"]
  node_n4[("Databases<br/>reference data")]
end

subgraph group_g2["Core analysis"]
  node_n5["Enrichment<br/>analysis entrypoint"]
  node_n6["GSEA<br/>analysis entrypoint"]
  node_n7(("Result object<br/>canonical output"))
end

subgraph group_g3["Downstream interpretation"]
  node_n8["Result plots<br/>visualization"]
  node_n9["GSEA plots<br/>visualization"]
  node_n10["Recluster<br/>interpretation"]
  node_n11["Pretty table<br/>reporting"]
  node_n12["AI annotation"]
  node_n13["Inference<br/>analysis downstream"]
end

node_n1["EnrichGT<br/>R package"]

node_n2 -->|"feeds"| node_n5
node_n3 -->|"feeds"| node_n6
node_n4 -->|"supports"| node_n5
node_n4 -->|"supports"| node_n6
node_n5 -->|"produces"| node_n7
node_n6 -->|"produces"| node_n7
node_n7 -->|"visualized by"| node_n8
node_n7 -->|"visualized by"| node_n9
node_n7 -->|"reclustered by"| node_n10
node_n10 -->|"reports"| node_n11
node_n10 -->|"annotates"| node_n12
node_n10 -->|"supplies"| node_n13
node_n1 -.->|"contains"| node_n2
node_n1 -.->|"contains"| node_n4
node_n1 -.->|"contains"| node_n8

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_n2,node_n3,node_n4 toneBlue
class node_n5,node_n6,node_n7 toneAmber
class node_n8,node_n9,node_n10,node_n11,node_n12,node_n13 toneMint
class node_n1 toneNeutral
```

## Components

### Inputs & data

Gene inputs and reference databases that feed analysis.

- **Gene list**: input · Plain gene input for standard enrichment analysis.
- **Weighted genes**: input · Ranked or weighted gene input for GSEA-style analysis.
- **Databases**: reference data · Pathway or gene-set reference data accessed through database_* functions.

### Core analysis

Primary enrichment and GSEA entry points plus shared result object.

- **Enrichment**: analysis entrypoint · egt_enrichment_analysis: standard enrichment workflow.
- **GSEA**: analysis entrypoint · egt_gsea_analysis: weighted gene set enrichment workflow.
- **Result object**: canonical output · Shared enriched-result representation handed to downstream features.

### Downstream interpretation

Plotting, reclustering, annotation, and inference built on the shared results.

- **Result plots**: visualization · egt_plot_results: plots enrichment outputs from the shared result object.
- **GSEA plots**: visualization · egt_plot_gsea: plots GSEA outputs.
- **Recluster**: interpretation · egt_recluster_analysis: reorganizes enriched results into gene clusters or modules.
- **Pretty table**: reporting · Human-readable tabular output from reclustering.
- **AI annotation**: annotation · Higher-level interpretation layer produced by reclustering.
- **Inference**: analysis downstream · egt_infer: pathway activity and transcription-factor inference from gene modules.

### Other components

- **EnrichGT**: R package · Experimental single-package workflow for gene set enrichment-style analysis.

## Connections

- Gene list → Enrichment: feeds · Plain gene input enters standard enrichment.
- Weighted genes → GSEA: feeds · Weighted genes enter GSEA-style analysis.
- Databases → Enrichment: supports · Reference databases are consumed by enrichment analysis.
- Databases → GSEA: supports · Reference databases are consumed by GSEA analysis.
- Enrichment → Result object: produces · Standard enrichment returns the shared result object.
- GSEA → Result object: produces · GSEA returns the shared result object.
- Result object → Result plots: visualized by · Enrichment results are plotted through the main plotting path.
- Result object → GSEA plots: visualized by · GSEA results are plotted through the dedicated GSEA plotting path.
- Result object → Recluster: reclustered by · The shared result object can be reorganized into clusters or modules.
- Recluster → Pretty table: reports · Reclustering produces a human-review table.
- Recluster → AI annotation: annotates · Reclustering produces AI-oriented annotations.
- Recluster → Inference: supplies · Gene modules from reclustering feed downstream inference.
- EnrichGT → Gene list: contains · Package boundary around the gene-input workflow.
- EnrichGT → Databases: contains · Package boundary around the database access layer.
- EnrichGT → Result plots: contains · Package boundary around result visualization.
