# xieresearchgroup/code-ae architecture

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

- Interactive diagram: https://gitdiagram.com/xieresearchgroup/code-ae
- Repository: https://github.com/xieresearchgroup/code-ae

## Overview

CODE-AE is a research implementation for learning context-aware gene-expression representations and predicting personalized drug response. Its principal workflow is to prepare expression and response data, pre-train an encoder across contexts, fine-tune a response predictor for selected drugs, and produce predictions or benchmark results. The README also documents TCGA inference, encoded-feature export, ADAE experiments, and baseline comparisons. Source excerpts show model and data-loader behavior; unsampled modules are included where documented, but their internal calls are not inferred.

Main entry points: [`code/pretrain_hyper_main.py`](https://github.com/xieresearchgroup/code-ae/blob/main/code/pretrain_hyper_main.py) (Pretraining entrypoint), [`code/dsn_ae.py`](https://github.com/xieresearchgroup/code-ae/blob/main/code/dsn_ae.py) (Domain-separation AE), [`code/data.py`](https://github.com/xieresearchgroup/code-ae/blob/main/code/data.py) (Response data loaders), [`code/drug_ft_hyper_main.py`](https://github.com/xieresearchgroup/code-ae/blob/main/code/drug_ft_hyper_main.py) (Fine-tuning entrypoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_data_config["Dataset configuration<br/>[data_config.py]"]
  node_data_prep["Expression preprocessing"]
  node_data_loaders["Response data loaders<br/>[data.py]"]
end

subgraph group_models["Representation learning"]
  node_pretrain_entry["Pretraining entrypoint"]
  node_ae_models["AE and VAE models<br/>[ae.py]"]
  node_dsn_model["Domain-separation AE<br/>[dsn_ae.py]"]
  node_train_ae["AE training<br/>[train_ae.py]"]
  node_train_adae["ADAE training<br/>[train_adae.py]"]
  node_train_code_base["CODE base training<br/>[train_code_base.py]"]
  node_train_code_adv["CODE adversarial training<br/>[train_code_adv.py]"]
  node_train_code_mmd["CODE MMD training<br/>[train_code_mmd.py]"]
  node_train_coral["CORAL training<br/>[train_coral.py]"]
  node_train_dae["Denoising AE training<br/>[train_dae.py]"]
  node_train_dsn["DSN training<br/>[train_dsn.py]"]
  node_train_dsna["DSNA training<br/>[train_dsna.py]"]
  node_train_vae["VAE training<br/>[train_vae.py]"]
end

subgraph group_prediction["Drug prediction"]
  node_drug_ft_entry["Fine-tuning entrypoint"]
  node_fine_tuning["Response fine-tuning<br/>[fine_tuning.py]"]
  node_inference_entry["TCGA inference entrypoint"]
  node_inference["Prediction inference<br/>[inference.py]"]
end

subgraph group_analysis["Evaluation and outputs"]
  node_feature_export["Encoded feature export"]
  node_baseline["ML baselines<br/>[ml_baseline.py]"]
  node_mlp_benchmark["MLP benchmark<br/>[mlp_main.py]"]
  node_tcrp_benchmark["TCRP benchmark<br/>[tcrp_main.py]"]
  node_vaen_benchmark["VAEN benchmark<br/>[vaen_main.py]"]
  node_metrics["Evaluation metrics"]
end

node_researcher(("Researcher"))
node_benchmark_data[("Benchmark data")]
node_outputs["Predictions and results"]

node_researcher -->|"runs pretraining"| node_pretrain_entry
node_pretrain_entry -.->|"prepares data"| node_data_loaders
node_pretrain_entry -.->|"selects method"| node_train_ae
node_pretrain_entry -.->|"selects method"| node_train_adae
node_pretrain_entry -.->|"selects method"| node_train_code_base
node_pretrain_entry -.->|"selects method"| node_train_code_adv
node_pretrain_entry -.->|"selects method"| node_train_code_mmd
node_pretrain_entry -.->|"selects method"| node_train_coral
node_pretrain_entry -.->|"selects method"| node_train_dae
node_pretrain_entry -.->|"selects method"| node_train_dsn
node_pretrain_entry -.->|"selects method"| node_train_dsna
node_pretrain_entry -.->|"selects method"| node_train_vae
node_train_ae -->|"trains model"| node_ae_models
node_train_adae -->|"trains model"| node_ae_models
node_train_code_base -->|"trains model"| node_dsn_model
node_train_code_adv -->|"trains model"| node_dsn_model
node_train_code_mmd -->|"trains model"| node_dsn_model
node_train_dsn -->|"trains model"| node_dsn_model
node_train_dsna -->|"trains model"| node_dsn_model
node_train_vae -->|"trains model"| node_ae_models
node_researcher -->|"runs fine-tuning"| node_drug_ft_entry
node_drug_ft_entry -.->|"prepares data"| node_data_loaders
node_drug_ft_entry -->|"fine-tunes encoder"| node_fine_tuning
node_fine_tuning -->|"evaluates model"| node_metrics
node_researcher -->|"runs inference"| node_inference_entry
node_inference_entry -.->|"generates predictions"| node_inference
node_inference_entry -->|"produces predictions"| node_outputs
node_researcher -->|"exports features"| node_feature_export
node_feature_export -->|"writes features"| node_outputs
node_researcher -->|"runs baseline"| node_baseline
node_researcher -->|"runs benchmark"| node_mlp_benchmark
node_researcher -->|"runs benchmark"| node_tcrp_benchmark
node_researcher -->|"runs benchmark"| node_vaen_benchmark
node_benchmark_data -.->|"provides datasets"| node_data_loaders
node_data_config -->|"configures sources"| node_data_prep
node_data_config -->|"configures sources"| node_data_loaders

click node_data_config "https://github.com/xieresearchgroup/code-ae/blob/main/code/data_config.py"
click node_data_prep "https://github.com/xieresearchgroup/code-ae/blob/main/code/data_preprocessing.py"
click node_data_loaders "https://github.com/xieresearchgroup/code-ae/blob/main/code/data.py"
click node_pretrain_entry "https://github.com/xieresearchgroup/code-ae/blob/main/code/pretrain_hyper_main.py"
click node_ae_models "https://github.com/xieresearchgroup/code-ae/blob/main/code/ae.py"
click node_dsn_model "https://github.com/xieresearchgroup/code-ae/blob/main/code/dsn_ae.py"
click node_train_ae "https://github.com/xieresearchgroup/code-ae/blob/main/code/train_ae.py"
click node_train_adae "https://github.com/xieresearchgroup/code-ae/blob/main/code/train_adae.py"
click node_train_code_base "https://github.com/xieresearchgroup/code-ae/blob/main/code/train_code_base.py"
click node_train_code_adv "https://github.com/xieresearchgroup/code-ae/blob/main/code/train_code_adv.py"
click node_train_code_mmd "https://github.com/xieresearchgroup/code-ae/blob/main/code/train_code_mmd.py"
click node_train_coral "https://github.com/xieresearchgroup/code-ae/blob/main/code/train_coral.py"
click node_train_dae "https://github.com/xieresearchgroup/code-ae/blob/main/code/train_dae.py"
click node_train_dsn "https://github.com/xieresearchgroup/code-ae/blob/main/code/train_dsn.py"
click node_train_dsna "https://github.com/xieresearchgroup/code-ae/blob/main/code/train_dsna.py"
click node_train_vae "https://github.com/xieresearchgroup/code-ae/blob/main/code/train_vae.py"
click node_drug_ft_entry "https://github.com/xieresearchgroup/code-ae/blob/main/code/drug_ft_hyper_main.py"
click node_fine_tuning "https://github.com/xieresearchgroup/code-ae/blob/main/code/fine_tuning.py"
click node_inference_entry "https://github.com/xieresearchgroup/code-ae/blob/main/code/drug_inference_main.py"
click node_inference "https://github.com/xieresearchgroup/code-ae/blob/main/code/inference.py"
click node_feature_export "https://github.com/xieresearchgroup/code-ae/blob/main/code/generate_encoded_features.py"
click node_baseline "https://github.com/xieresearchgroup/code-ae/blob/main/code/ml_baseline.py"
click node_mlp_benchmark "https://github.com/xieresearchgroup/code-ae/blob/main/code/mlp_main.py"
click node_tcrp_benchmark "https://github.com/xieresearchgroup/code-ae/blob/main/code/tcrp_main.py"
click node_vaen_benchmark "https://github.com/xieresearchgroup/code-ae/blob/main/code/vaen_main.py"
click node_metrics "https://github.com/xieresearchgroup/code-ae/blob/main/code/evaluation_utils.py"

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_data_config,node_data_prep,node_data_loaders toneBlue
class node_pretrain_entry,node_ae_models,node_dsn_model,node_train_ae,node_train_adae,node_train_code_base,node_train_code_adv,node_train_code_mmd,node_train_coral,node_train_dae,node_train_dsn,node_train_dsna,node_train_vae,node_benchmark_data toneAmber
class node_drug_ft_entry,node_fine_tuning,node_inference_entry,node_inference toneMint
class node_feature_export,node_baseline,node_mlp_benchmark,node_tcrp_benchmark,node_vaen_benchmark,node_metrics toneRose
class node_researcher,node_outputs toneIndigo
```

## Components

### Data preparation

- [Dataset configuration](https://github.com/xieresearchgroup/code-ae/blob/main/code/data_config.py): `code/data_config.py`
- [Expression preprocessing](https://github.com/xieresearchgroup/code-ae/blob/main/code/data_preprocessing.py): `code/data_preprocessing.py`
- [Response data loaders](https://github.com/xieresearchgroup/code-ae/blob/main/code/data.py): `code/data.py`

### Representation learning

- [Pretraining entrypoint](https://github.com/xieresearchgroup/code-ae/blob/main/code/pretrain_hyper_main.py): `code/pretrain_hyper_main.py`
- [AE and VAE models](https://github.com/xieresearchgroup/code-ae/blob/main/code/ae.py): `code/ae.py`
- [Domain-separation AE](https://github.com/xieresearchgroup/code-ae/blob/main/code/dsn_ae.py): `code/dsn_ae.py`
- [AE training](https://github.com/xieresearchgroup/code-ae/blob/main/code/train_ae.py): `code/train_ae.py`
- [ADAE training](https://github.com/xieresearchgroup/code-ae/blob/main/code/train_adae.py): `code/train_adae.py`
- [CODE base training](https://github.com/xieresearchgroup/code-ae/blob/main/code/train_code_base.py): `code/train_code_base.py`
- [CODE adversarial training](https://github.com/xieresearchgroup/code-ae/blob/main/code/train_code_adv.py): `code/train_code_adv.py`
- [CODE MMD training](https://github.com/xieresearchgroup/code-ae/blob/main/code/train_code_mmd.py): `code/train_code_mmd.py`
- [CORAL training](https://github.com/xieresearchgroup/code-ae/blob/main/code/train_coral.py): `code/train_coral.py`
- [Denoising AE training](https://github.com/xieresearchgroup/code-ae/blob/main/code/train_dae.py): `code/train_dae.py`
- [DSN training](https://github.com/xieresearchgroup/code-ae/blob/main/code/train_dsn.py): `code/train_dsn.py`
- [DSNA training](https://github.com/xieresearchgroup/code-ae/blob/main/code/train_dsna.py): `code/train_dsna.py`
- [VAE training](https://github.com/xieresearchgroup/code-ae/blob/main/code/train_vae.py): `code/train_vae.py`

### Drug prediction

- [Fine-tuning entrypoint](https://github.com/xieresearchgroup/code-ae/blob/main/code/drug_ft_hyper_main.py): `code/drug_ft_hyper_main.py`
- [Response fine-tuning](https://github.com/xieresearchgroup/code-ae/blob/main/code/fine_tuning.py): `code/fine_tuning.py`
- [TCGA inference entrypoint](https://github.com/xieresearchgroup/code-ae/blob/main/code/drug_inference_main.py): `code/drug_inference_main.py`
- [Prediction inference](https://github.com/xieresearchgroup/code-ae/blob/main/code/inference.py): `code/inference.py`

### Evaluation and outputs

- [Encoded feature export](https://github.com/xieresearchgroup/code-ae/blob/main/code/generate_encoded_features.py): `code/generate_encoded_features.py`
- [ML baselines](https://github.com/xieresearchgroup/code-ae/blob/main/code/ml_baseline.py): `code/ml_baseline.py`
- [MLP benchmark](https://github.com/xieresearchgroup/code-ae/blob/main/code/mlp_main.py): `code/mlp_main.py`
- [TCRP benchmark](https://github.com/xieresearchgroup/code-ae/blob/main/code/tcrp_main.py): `code/tcrp_main.py`
- [VAEN benchmark](https://github.com/xieresearchgroup/code-ae/blob/main/code/vaen_main.py): `code/vaen_main.py`
- [Evaluation metrics](https://github.com/xieresearchgroup/code-ae/blob/main/code/evaluation_utils.py): `code/evaluation_utils.py`

### Other components

- **Researcher**
- **Benchmark data**
- **Predictions and results**

## Connections

- Researcher → Pretraining entrypoint: runs pretraining (evidence: `README.md`)
- Pretraining entrypoint → Response data loaders: prepares data (evidence: `code/pretrain_hyper_main.py`)
- Pretraining entrypoint → AE training: selects method (evidence: `code/pretrain_hyper_main.py`)
- Pretraining entrypoint → ADAE training: selects method (evidence: `code/pretrain_hyper_main.py`)
- Pretraining entrypoint → CODE base training: selects method (evidence: `code/pretrain_hyper_main.py`)
- Pretraining entrypoint → CODE adversarial training: selects method (evidence: `code/pretrain_hyper_main.py`)
- Pretraining entrypoint → CODE MMD training: selects method (evidence: `code/pretrain_hyper_main.py`)
- Pretraining entrypoint → CORAL training: selects method (evidence: `code/pretrain_hyper_main.py`)
- Pretraining entrypoint → Denoising AE training: selects method (evidence: `code/pretrain_hyper_main.py`)
- Pretraining entrypoint → DSN training: selects method (evidence: `code/pretrain_hyper_main.py`)
- Pretraining entrypoint → DSNA training: selects method (evidence: `code/pretrain_hyper_main.py`)
- Pretraining entrypoint → VAE training: selects method (evidence: `code/pretrain_hyper_main.py`)
- AE training → AE and VAE models: trains model (evidence: `code/ae.py`)
- ADAE training → AE and VAE models: trains model (evidence: `code/train_adae.py`)
- CODE base training → Domain-separation AE: trains model (evidence: `code/train_code_base.py`)
- CODE adversarial training → Domain-separation AE: trains model (evidence: `code/train_code_adv.py`)
- CODE MMD training → Domain-separation AE: trains model (evidence: `code/train_code_mmd.py`)
- DSN training → Domain-separation AE: trains model (evidence: `code/train_dsn.py`)
- DSNA training → Domain-separation AE: trains model (evidence: `code/train_dsna.py`)
- VAE training → AE and VAE models: trains model (evidence: `code/train_vae.py`)
- Researcher → Fine-tuning entrypoint: runs fine-tuning (evidence: `README.md`)
- Fine-tuning entrypoint → Response data loaders: prepares data (evidence: `code/drug_ft_hyper_main.py`)
- Fine-tuning entrypoint → Response fine-tuning: fine-tunes encoder (evidence: `README.md`)
- Response fine-tuning → Evaluation metrics: evaluates model (evidence: `code/fine_tuning.py`)
- Researcher → TCGA inference entrypoint: runs inference (evidence: `README.md`)
- TCGA inference entrypoint → Prediction inference: generates predictions
- TCGA inference entrypoint → Predictions and results: produces predictions (evidence: `README.md`)
- Researcher → Encoded feature export: exports features (evidence: `README.md`)
- Encoded feature export → Predictions and results: writes features (evidence: `README.md`)
- Researcher → ML baselines: runs baseline (evidence: `README.md`)
- Researcher → MLP benchmark: runs benchmark (evidence: `README.md`)
- Researcher → TCRP benchmark: runs benchmark (evidence: `README.md`)
- Researcher → VAEN benchmark: runs benchmark (evidence: `README.md`)
- Benchmark data → Response data loaders: provides datasets
- Dataset configuration → Expression preprocessing: configures sources (evidence: `code/data_preprocessing.py`)
- Dataset configuration → Response data loaders: configures sources (evidence: `code/data.py`)
