Skip to content
StaGillPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HADiGCN: Code for the Hierarchy-Aware Differential GCN (HADiGCN)

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.

Repository Structure

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.

Installation and Setup

Prerequisites

You will need Python 3.8+ and a standard scientific computing environment.

1. Clone the Repository

git clone [REPO_URL]
cd HADiGCN

2. Set up Environment (Recommended)

conda create -n hadigcn python=3.9
conda activate hadigcn

3. Install Dependencies

This 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 .

Running the Experiments

1. Pancreas Experiment (Cross-Dataset)

python examples/pancreas/example_pancreas_full.py

2. DLPFC Experiment (Spatial Classification)

python examples/dlpfc/example_dlpfc_full.py

3. Simulation Experiments

python examples/simulation/simulation_example.py

4. Top-k Alpha Tuning

python examples/simulation/example_tuning_alpha.py

Debug Mode

The 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 --debug

Acknowledgement

The 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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages