# hayatlab/cart_llms architecture

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

- Interactive diagram: https://gitdiagram.com/hayatlab/cart_llms
- Repository: https://github.com/hayatlab/cart_llms

## Overview

#### Purpose and entry points
This repository implements a CART nomination workflow: score candidate genes using expression, protein-atlas, clinical-trial, and differential-expression evidence, then use LLM prompts to prioritize candidates. The main executable entry points are Python scripts for model/prompt variants and R scripts/notebooks for evidence generation.

#### Evidence-generation layer
Expression and tissue-specific evidence are produced from GTEx and protein-expression sources. `gtex_scoring.R` and `protein_exp.py` appear to generate inputs used by downstream aggregation, with persisted outputs under `reproduce/gtex_results/median_expression_results.csv` and `reproduce/protein_expression/protein_expression_results_with_tissues.csv`.

Protein Atlas evidence is handled separately through `HumanProteinAtlas.ipynb`, `Protein_Expression_Scoring.ipynb`, and the reproduced score table `reproduce/Protein_Atlas_results/gene_scores_skin.csv`.

#### Differential expression and atlas analysis
`de_scoring.R` provides an R-based differential-expression scoring stage. Skin-focused exploratory/downstream analysis is represented by `malignant_skin_atlas_downstream_v2.ipynb` and `Heatmap.ipynb`, with materialized heatmap results at `reproduce/heatmap_results/skin_results.csv`.

#### Clinical-trial evidence
`clinical_trials_scoring.ipynb` derives a distinct clinical-trial signal, persisted as `reproduce/clinical_trials/clinical_trial_scores.csv`. This is an independent evidence boundary feeding the candidate-ranking process rather than an LLM-generated source.

#### Score aggregation and prompt preparation
`Score_Aggregation.ipynb` combines evidence streams into weighted gene-score datasets. Prompt-ready variants encode alternative weighting policies—balanced, equal, expression, heatmap, HPA, and clinical-trial emphasis—under `reproduce/llm_prompt_prep/`, including `reproduce/llm_prompt_prep/gene_scores_expression_emphasis.csv`.

The `llm_prompt_prep/gene_scores_expression_emphasis.csv` path is a working prompt-preparation input outside the reproducibility snapshot.

#### LLM nomination variants
The LLM stage has four parallel experimental modes: baseline (`gemini_model.py`, `prompt_2_new.py`), bulk review (`gemini_model_bulk.py`, `prompt_2_new_bulk.py`), no-base-context (`gemini_model_no_base.py`, `prompt_2_new_no_base.py`), and zero-shot (`gemini_model_zero_shot.py`, `prompt_2_new_zero_shot.py`). Corresponding visualization notebooks, such as `llm_prompt1_visual.ipynb` and `llm_prompt1_visual_zero_shot.ipynb`, inspect or compare model outputs.

`multi_request.py` is the likely orchestration boundary for issuing multiple LLM requests. The model scripts indicate an external Gemini service dependency; credentials, request configuration, and response persistence are not present in the supplied tree.

#### Reproducibility boundary
`reproduce/` is the packaged data/artifact layer: it contains source-like input data, generated evidence scores, prompt-preparation CSVs, and environment definitions in `reproduce/environment.yml` and `reproduce/updated_requirements.txt`. The bulk expression input `reproduce/bulk_review/gene_reads_v10_skin_sun_exposed_lower_leg.gct.gz` supports the bulk-review branch.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_evidence["Evidence generation"]
  node_gtex["GTEx scoring<br/>R scoring script<br/>[gtex_scoring.R]"]
  node_protein_expression["Protein expression scoring<br/>Python scoring script<br/>[protein_exp.py]"]
  node_protein_atlas["Protein Atlas scoring<br/>analysis notebooks"]
  node_de["Differential expression<br/>R scoring script<br/>[de_scoring.R]"]
  node_clinical_trials["Clinical-trial scoring<br/>analysis notebook"]
end

subgraph group_analysis["Aggregation and analysis"]
  node_skin_analysis["Skin atlas analysis<br/>analysis notebook"]
  node_aggregation["Score aggregation<br/>aggregation notebook"]
end

subgraph group_llm["LLM nomination"]
  node_request_orchestrator["Multi-request orchestration<br/>Python script<br/>[multi_request.py]"]
  node_baseline_llm["Baseline nomination<br/>Gemini prompt variant<br/>[gemini_model.py]"]
  node_bulk_llm["Bulk-review nomination<br/>Gemini prompt variant"]
  node_context_variants["Context ablations<br/>Gemini prompt variants"]
  node_gemini{{"Gemini service<br/>external LLM API"}}
  node_output_visuals["Nomination visualizations<br/>analysis notebooks"]
end

subgraph group_artifacts["Reproducibility artifacts"]
  node_gtex_scores["GTEx score table<br/>CSV artifact"]
  node_protein_scores["Protein tissue score table<br/>CSV artifact"]
  node_hpa_scores["Protein Atlas scores<br/>CSV artifact"]
  node_clinical_scores["Clinical-trial scores<br/>CSV artifact"]
  node_heatmap_results["Skin heatmap results<br/>CSV artifact<br/>[skin_results.csv]"]
  node_prompt_scores["Prompt-ready score variants<br/>CSV datasets"]
  node_bulk_input["Bulk expression input<br/>GCT dataset"]
end

node_gtex -->|"produces"| node_gtex_scores
node_protein_expression -->|"produces"| node_protein_scores
node_protein_atlas -->|"produces"| node_hpa_scores
node_clinical_trials -->|"produces"| node_clinical_scores
node_de -->|"differential-expression evidence"| node_aggregation
node_gtex_scores -->|"expression evidence"| node_aggregation
node_protein_scores -->|"protein evidence"| node_aggregation
node_hpa_scores -->|"atlas evidence"| node_aggregation
node_clinical_scores -->|"clinical evidence"| node_aggregation
node_skin_analysis -->|"materializes"| node_heatmap_results
node_heatmap_results -->|"skin/heatmap evidence"| node_aggregation
node_aggregation -->|"creates weighted variants"| node_prompt_scores
node_prompt_scores -->|"candidate input"| node_baseline_llm
node_prompt_scores -->|"candidate input"| node_bulk_llm
node_bulk_input -->|"bulk-review input"| node_bulk_llm
node_prompt_scores -->|"candidate input"| node_context_variants
node_request_orchestrator -->|"orchestrates requests"| node_baseline_llm
node_request_orchestrator -->|"orchestrates requests"| node_bulk_llm
node_request_orchestrator -->|"orchestrates requests"| node_context_variants
node_baseline_llm -->|"prompts"| node_gemini
node_bulk_llm -->|"prompts"| node_gemini
node_context_variants -->|"prompts"| node_gemini
node_baseline_llm -.->|"outputs inspected"| node_output_visuals
node_context_variants -.->|"outputs compared"| node_output_visuals

click node_gtex "https://github.com/hayatlab/cart_llms/blob/main/gtex_scoring.R"
click node_protein_expression "https://github.com/hayatlab/cart_llms/blob/main/protein_exp.py"
click node_protein_atlas "https://github.com/hayatlab/cart_llms/blob/main/HumanProteinAtlas.ipynb"
click node_de "https://github.com/hayatlab/cart_llms/blob/main/de_scoring.R"
click node_clinical_trials "https://github.com/hayatlab/cart_llms/blob/main/clinical_trials_scoring.ipynb"
click node_gtex_scores "https://github.com/hayatlab/cart_llms/blob/main/reproduce/gtex_results/median_expression_results.csv"
click node_protein_scores "https://github.com/hayatlab/cart_llms/blob/main/reproduce/protein_expression/protein_expression_results_with_tissues.csv"
click node_hpa_scores "https://github.com/hayatlab/cart_llms/blob/main/reproduce/Protein_Atlas_results/gene_scores_skin.csv"
click node_clinical_scores "https://github.com/hayatlab/cart_llms/blob/main/reproduce/clinical_trials/clinical_trial_scores.csv"
click node_skin_analysis "https://github.com/hayatlab/cart_llms/blob/main/malignant_skin_atlas_downstream_v2.ipynb"
click node_heatmap_results "https://github.com/hayatlab/cart_llms/blob/main/reproduce/heatmap_results/skin_results.csv"
click node_aggregation "https://github.com/hayatlab/cart_llms/blob/main/Score_Aggregation.ipynb"
click node_prompt_scores "https://github.com/hayatlab/cart_llms/blob/main/reproduce/llm_prompt_prep/gene_scores_expression_emphasis.csv"
click node_bulk_input "https://github.com/hayatlab/cart_llms/blob/main/reproduce/bulk_review/gene_reads_v10_skin_sun_exposed_lower_leg.gct.gz"
click node_request_orchestrator "https://github.com/hayatlab/cart_llms/blob/main/multi_request.py"
click node_baseline_llm "https://github.com/hayatlab/cart_llms/blob/main/gemini_model.py"
click node_bulk_llm "https://github.com/hayatlab/cart_llms/blob/main/gemini_model_bulk.py"
click node_context_variants "https://github.com/hayatlab/cart_llms/blob/main/gemini_model_no_base.py"
click node_output_visuals "https://github.com/hayatlab/cart_llms/blob/main/llm_prompt1_visual.ipynb"

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_gtex,node_protein_expression,node_protein_atlas,node_de,node_clinical_trials toneBlue
class node_skin_analysis,node_aggregation toneAmber
class node_request_orchestrator,node_baseline_llm,node_bulk_llm,node_context_variants,node_gemini,node_output_visuals toneMint
class node_gtex_scores,node_protein_scores,node_hpa_scores,node_clinical_scores,node_heatmap_results,node_prompt_scores,node_bulk_input toneRose
```

## Components

### Evidence generation

Independent biological and clinical scoring streams.

- [GTEx scoring](https://github.com/hayatlab/cart_llms/blob/main/gtex_scoring.R): R scoring script · `gtex_scoring.R`
- [Protein expression scoring](https://github.com/hayatlab/cart_llms/blob/main/protein_exp.py): Python scoring script · `protein_exp.py`
- [Protein Atlas scoring](https://github.com/hayatlab/cart_llms/blob/main/HumanProteinAtlas.ipynb): analysis notebooks · `HumanProteinAtlas.ipynb`
- [Differential expression](https://github.com/hayatlab/cart_llms/blob/main/de_scoring.R): R scoring script · `de_scoring.R`
- [Clinical-trial scoring](https://github.com/hayatlab/cart_llms/blob/main/clinical_trials_scoring.ipynb): analysis notebook · `clinical_trials_scoring.ipynb`

### Aggregation and analysis

Score combination and skin-focused downstream analysis.

- [Skin atlas analysis](https://github.com/hayatlab/cart_llms/blob/main/malignant_skin_atlas_downstream_v2.ipynb): analysis notebook · `malignant_skin_atlas_downstream_v2.ipynb`
- [Score aggregation](https://github.com/hayatlab/cart_llms/blob/main/Score_Aggregation.ipynb): aggregation notebook · Combines evidence into weighted gene-score variants. · `Score_Aggregation.ipynb`

### LLM nomination

Parallel Gemini prompting experiments.

- [Multi-request orchestration](https://github.com/hayatlab/cart_llms/blob/main/multi_request.py): Python script · Issues multiple external LLM requests. · `multi_request.py`
- [Baseline nomination](https://github.com/hayatlab/cart_llms/blob/main/gemini_model.py): Gemini prompt variant · `gemini_model.py`
- [Bulk-review nomination](https://github.com/hayatlab/cart_llms/blob/main/gemini_model_bulk.py): Gemini prompt variant · `gemini_model_bulk.py`
- [Context ablations](https://github.com/hayatlab/cart_llms/blob/main/gemini_model_no_base.py): Gemini prompt variants · No-base-context and zero-shot experiments. · `gemini_model_no_base.py`
- **Gemini service**: external LLM API · External candidate-prioritization dependency.
- [Nomination visualizations](https://github.com/hayatlab/cart_llms/blob/main/llm_prompt1_visual.ipynb): analysis notebooks · `llm_prompt1_visual.ipynb`

### Reproducibility artifacts

Packaged datasets and generated score tables.

- [GTEx score table](https://github.com/hayatlab/cart_llms/blob/main/reproduce/gtex_results/median_expression_results.csv): CSV artifact · `reproduce/gtex_results/median_expression_results.csv`
- [Protein tissue score table](https://github.com/hayatlab/cart_llms/blob/main/reproduce/protein_expression/protein_expression_results_with_tissues.csv): CSV artifact · `reproduce/protein_expression/protein_expression_results_with_tissues.csv`
- [Protein Atlas scores](https://github.com/hayatlab/cart_llms/blob/main/reproduce/Protein_Atlas_results/gene_scores_skin.csv): CSV artifact · `reproduce/Protein_Atlas_results/gene_scores_skin.csv`
- [Clinical-trial scores](https://github.com/hayatlab/cart_llms/blob/main/reproduce/clinical_trials/clinical_trial_scores.csv): CSV artifact · `reproduce/clinical_trials/clinical_trial_scores.csv`
- [Skin heatmap results](https://github.com/hayatlab/cart_llms/blob/main/reproduce/heatmap_results/skin_results.csv): CSV artifact · `reproduce/heatmap_results/skin_results.csv`
- [Prompt-ready score variants](https://github.com/hayatlab/cart_llms/blob/main/reproduce/llm_prompt_prep/gene_scores_expression_emphasis.csv): CSV datasets · Balanced and emphasis-weighted candidate inputs. · `reproduce/llm_prompt_prep/gene_scores_expression_emphasis.csv`
- [Bulk expression input](https://github.com/hayatlab/cart_llms/blob/main/reproduce/bulk_review/gene_reads_v10_skin_sun_exposed_lower_leg.gct.gz): GCT dataset · `reproduce/bulk_review/gene_reads_v10_skin_sun_exposed_lower_leg.gct.gz`

## Connections

- GTEx scoring → GTEx score table: produces
- Protein expression scoring → Protein tissue score table: produces
- Protein Atlas scoring → Protein Atlas scores: produces
- Clinical-trial scoring → Clinical-trial scores: produces
- Differential expression → Score aggregation: differential-expression evidence
- GTEx score table → Score aggregation: expression evidence
- Protein tissue score table → Score aggregation: protein evidence
- Protein Atlas scores → Score aggregation: atlas evidence
- Clinical-trial scores → Score aggregation: clinical evidence
- Skin atlas analysis → Skin heatmap results: materializes
- Skin heatmap results → Score aggregation: skin/heatmap evidence
- Score aggregation → Prompt-ready score variants: creates weighted variants
- Prompt-ready score variants → Baseline nomination: candidate input
- Prompt-ready score variants → Bulk-review nomination: candidate input
- Bulk expression input → Bulk-review nomination: bulk-review input
- Prompt-ready score variants → Context ablations: candidate input
- Multi-request orchestration → Baseline nomination: orchestrates requests
- Multi-request orchestration → Bulk-review nomination: orchestrates requests
- Multi-request orchestration → Context ablations: orchestrates requests
- Baseline nomination → Gemini service: prompts
- Bulk-review nomination → Gemini service: prompts
- Context ablations → Gemini service: prompts
- Baseline nomination → Nomination visualizations: outputs inspected
- Context ablations → Nomination visualizations: outputs compared
