DyGraphTrans: A Temporal Graph Representation Learning Framework for Modeling Disease Progression from Electronic Health Records
DyGraphTrans is designed to predict future outcomes from dynamic EHR graphs by capturing local temporal dependencies and long-range global trends within a sliding window. Unlike static GNNs, DyGraphTrans updates its graph convolutional weights at every visit to model how message passing evolves over time. Instead of updating node embeddings, DyGraphTrans models temporal changes directly in the GNN parameters. In addition, DyGraphTrans extracts feature-level signals within each temporal window, enabling interpretable insights into clinical factors.
Figure 1. Overview of the proposed DyGraphTrans framework. (A) Each patient time point is represented as a graph, where nodes correspond to patients and edges represent patient similarity computed using Similarity Network Fusion (SNF) on multimodal EHR data.(B) After neighborhood message aggregation using a GNN, an RNN module updates the GNN layer weights using previous hidden states. The resulting sequence of GNN weights is processed through a Transformer using a sliding-window mechanism. After the first window, GNN weights are updated at every time point using weights generated by the RNN and Transformer. Finally, after processing all temporal graphs up to time t, a multilayer perceptron (MLP) classifier predicts the diagnosis Y at visit t + 1.
We evaluated DyGraphTrans on three longitudinal Electronic Health Record (EHR) datasets:
- ADNI: https://adni.loni.usc.edu/
- NACC: https://naccdata.org/
- MIMIC-IV v2.2: https://physionet.org In addition to EHR data, we evaluated DyGraphTrans on widely used benchmark dynamic graph datasets spanning citation networks, social networks, and biological graphs. All benchmark datasets are provided in the DyGraphTrans_Benchmark_Data directory.
For EHR data, a sample dataset is provided in the Data folder.
- Create a CSV file following the sample format (e.g., sample_id, timepoint, labels, etc.).
- Generate temporal graphs by running EHR_Temporal_Graphs.ipynb.This will create Data/data.npz, which contains a sequence of temporal graphs.
- Run DyGraphTrans_EHR.ipynb to generate prediction results and interpretation plots.
- Download the dataset from the official MIMIC-IV website.
- Place the data in the temporal folder.
- Run MIMIC_IV_Data_Processing.ipynb to process the raw data and generate temporal graphs.
- Run EHR_Temporal_Graphs.ipynb on the processed MIMIC data to generate prediction results and interpretation plots.
To run experiments on benchmark datasets:
- bash DyGraphTrans_Benchmark_Data/scripts/DyGraphTrans.sh Processed temporal graphs for benchmark datasets were generated using the method from https://github.com/EdisonLeeeee/GraphSSM/.
### EHR experiments for EHR_Temporal_Graphs.ipynb & DyGraphTrans_EHR.ipynb
conda env create -f requirements/env_EHR_DyGraphTrans.yml
conda activate DyGraphTrans_EHR
### MIMIC-IV preprocessing for MIMIC_IV_Data_Processing.ipynb file
conda env create -f requirements/env_mimic_DyGraphTrans.yml
conda activate DyGraphTrans_MIMIC
### Benchmark experiments for DyGraphTrans_Benchmark_Data
conda env create -f requirements/env_benchmark_DyGraphTrans.yml
conda activate DyGraphTrans_Benchmark