This repository provides the official implementation of the Hierarchy-Aware Differential Graph Convolutional Network (HADiGCN) developed in the work, including experiments for simulation, single-cell RNA-seq classification, and spatial transcriptomics annotation.
The core codebase is organized as a Python package, hadigcn, with dedicated scripts for running each major experiment.
| Directory / File | Description |
|---|---|
difftopk/ |
difftopk package dependency |
hadigcn/ |
The main Python package containing all reusable components. |
├── __init__.py |
Public API: Exports core classes, models, and utilities (HADiGCN, train, set_seed, etc.). |
├── models.py |
Defines the HADiGCN model and MLP baseline models. |
├── train.py |
Contains the reusable training loop logic (train, train_one_epoch, validate_one_epoch). |
├── loss_functions.py |
Defines TopKCrossEntropyLoss and CrossEntropyLossWrapper. |
└── utils.py |
General utilities, including data preprocessing helpers (high_var_npdata, sparse_mx_to_torch_sparse_tensor, etc.). |
examples/ |
Scripts for running the full set of thesis experiments. |
├── pancreas/ |
Pancreas (Baron → Segerstolpe) cross-dataset experiment. |
├── dlpfc/ |
DLPFC (Layer Classification) spatial transcriptomics experiment. |
└── simulation/ |
Synthetic experiments and alpha tuning runners. |
You will need Python 3.8+ and a standard scientific computing environment.
git clone [REPO_URL]
cd HADiGCNconda create -n hadigcn python=3.9
conda activate hadigcnThis project relies on PyTorch and PyTorch Geometric. Note: Adjust the torch_geometric installation based on your specific CUDA version (or omit cuda if using CPU-only).
# 1. Install Core PyTorch (Matches tested version 2.7.0)
pip install torch>=2.7.0
# 2. Install PyTorch Geometric (Includes core helpers)
pip install torch_geometric
# 3. Install HADiGCN and all its dependencies (including diffsort used by the difftopk internal package):
# This reads from your new pyproject.toml file
pip install -e .python examples/pancreas/example_pancreas_full.pypython examples/dlpfc/example_dlpfc_full.pypython examples/simulation/simulation_example.pypython examples/simulation/example_tuning_alpha.pyThe core experiment scripts (pancreas, dlpfc, simulation) support a --debug flag for rapid testing, which limits the run to a single seed and a small number of epochs (e.g., 3).
# Example: Quick test of the Pancreas experiment
python examples/example_pancreas_full.py --debugThe differentiable top-k logic is based on the difftopk library by Felix Petersen. For portability, a version of this package is bundled within this repository in the difftopk/ directory.
Original repository: https://github.com/Felix-Petersen/difftopk.