DMCB-GIST/ST-ConMa

Python

1

57 commits

updated Feb 21, 2026

See the code

README

ST-ConMa

Overview

πŸ’½ Datasets for downstream tasks


Encoders for ST-ConMa

Image Encoder

Gene Encoder


πŸ’½ Pre-processed training datasets, checkpoint and result files


πŸ—‚οΈ Project Structure

ST_ConMa_git/
β”œβ”€β”€ train_multitask.py              # Main multi-task training script
β”œβ”€β”€ run_train_multitask.sh          # Distributed training launcher
β”‚
β”œβ”€β”€ PathoDuet/
β”‚   β”œβ”€β”€ checkpoint/
β”‚       β”œβ”€β”€ checkpoint_HE.pth                    
β”‚
β”œβ”€β”€ utils/                          # Core training utilities
β”‚   β”œβ”€β”€ multimodal.py               # ST_AlignmentModel & Trainer
β”‚   β”œβ”€β”€ loss.py                     
β”‚   β”œβ”€β”€ dataset_load.py           
β”‚   β”œβ”€β”€ augmentations.py           
β”‚   β”œβ”€β”€ model.py                   
β”‚   β”œβ”€β”€ optimizer.py                
β”‚   β”œβ”€β”€ scheduler.py               
β”‚   β”œβ”€β”€ gather.py                   
β”‚   └── pt_load_inference.py        
β”‚
β”œβ”€β”€ pt_dataset/                     # Pre-training datasets
β”‚   β”œβ”€β”€ st_images/                  # ST tissue images
β”‚   └── st_sentences/               # Gene sentences
β”‚
β”œβ”€β”€ ft_dataset/                     # Fine-tuning datasets
β”‚   β”œβ”€β”€ gep_pred/                   # Gene expression prediction
β”‚   β”œβ”€β”€ spatial_clustering/         # Spatial clustering (DLPFC)
β”‚   └── linear_probing/             # Linear probing benchmarks
β”‚       β”œβ”€β”€ crc
β”‚       β”œβ”€β”€ mhist
β”‚       └── luad
β”‚
β”œβ”€β”€ evaluations/                    # Evaluation scripts
β”‚   β”œβ”€β”€ gep_pred/                   # Gene expression prediction
β”‚   β”‚   β”œβ”€β”€ eval_st_conma_zeroshot.py
β”‚   β”‚   β”œβ”€β”€ train_st_conma.py
β”‚   β”‚   └── run_st_conma_*.sh
β”‚   β”œβ”€β”€ linear_probing/             # Linear probing tasks
β”‚   β”‚   β”œβ”€β”€ cam17.py
β”‚   β”‚   β”œβ”€β”€ crcnorm.py
β”‚   β”‚   β”œβ”€β”€ luad.py
β”‚   β”‚   └── mhist.py
β”‚   β”œβ”€β”€ spatial_clustering/         # Spatial domain identification
β”‚   β”œβ”€β”€ st_linear_probing/          # ST-specific linear probing
β”‚   └── cluster_plot/               # Visualization utilities
β”‚
β”œβ”€β”€ checkpoints/                    # Saved model weights
└── results/                        # Evaluation results

🌏 Environment Setup

Two conda environments are required:

conda env create -f st_conma_env.yml
conda activate st_conma
pip install --no-deps --extra-index-url https://download.pytorch.org/whl/cu124 -r st_conma_pip.txt

# For spatial clustering with STAIG module
conda env create -f st_conma_clustering_env.yml
conda activate st_conma_clustering
pip install --no-deps -f https://data.pyg.org/whl/torch-2.2.0+cu121.html -r st_conma_clustering_pip.txt

πŸš€ Dataset Preparation

1. Download Pre-training and downstream datasets

We have uploaded pre-training, downstream datasets and result files on Google Drive. Access requests will be approved as quickly as possible.

Histopathology benchmark datasets can be downloaded from the links mentioned previously.


Pre-training

conda activate st_conma
bash run_train_multitask.sh

Evaluation

Note: Adjust the CUDA device in each script as needed.

K-means Clustering on Histopathology Benchmarks

conda activate st_conma
python ./evaluations/cluster_plot/cluster_plot_st_conma.py

Linear Probing on Histopathology Benchmarks

conda activate st_conma
python ./evaluations/linear_probing/cam17.py
python ./evaluations/linear_probing/crcnorm.py
python ./evaluations/linear_probing/luad.py
python ./evaluations/linear_probing/mhist.py

Gene Expression Prediction

Evaluated on HER2ST, cSCC, and HLT datasets.

conda activate st_conma
bash ./evaluations/gep_pred/run_st_conma_igc_igm.sh
bash ./evaluations/gep_pred/run_st_conma_zeroshot.sh

For visualization, run all cells in:

  • ./evaluations/gep_pred/CD24_viz.ipynb
  • ./evaluations/gep_pred/LGALS1_viz.ipynb

Linear Probing on DLPFC Dataset

conda activate st_conma
python ./evaluations/st_linear_probing/train_st_conma_ie_dlpfc.py
python ./evaluations/st_linear_probing/train_st_conma_ge_dlpfc.py
python ./evaluations/st_linear_probing/train_st_conma_fe_dlpfc.py

Spatial Clustering

Evaluated on DLPFC and Human Breast Cancer datasets.

# Fine-tuning
conda activate st_conma
bash ./evaluations/spatial_clustering/run_finetune_dlpfc.sh
bash ./evaluations/spatial_clustering/run_finetune_hbc.sh

# Extract fusion embeddings
bash ./evaluations/spatial_clustering/run_get_fusion_embeddings_dlpfc.sh
bash ./evaluations/spatial_clustering/run_get_fusion_embeddings_hbc.sh

# Clustering with STAIG module
conda activate st_conma_clustering
python ./evaluations/spatial_clustering/train_st_conma.py \
    --dataset dlpfc --all \
    --output_dir ./results/spatial_clustering/st_conma/dlpfc

python ./evaluations/spatial_clustering/train_st_conma.py \
    --dataset human_breast_cancer --all \
    --output_dir ./results/spatial_clustering/st_conma/human_breast_cancer

Human Breast Cancer Analysis

conda activate st_conma and run all cells in ./evaluations/spatial_clustering/spatial_clustering.ipynb.

DMCB-GIST/ST-ConMa

Python

1

57 commits

updated Feb 21, 2026

See the code

README

ST-ConMa

Overview

πŸ’½ Datasets for downstream tasks


Encoders for ST-ConMa

Image Encoder

Gene Encoder


πŸ’½ Pre-processed training datasets, checkpoint and result files


πŸ—‚οΈ Project Structure

ST_ConMa_git/
β”œβ”€β”€ train_multitask.py              # Main multi-task training script
β”œβ”€β”€ run_train_multitask.sh          # Distributed training launcher
β”‚
β”œβ”€β”€ PathoDuet/
β”‚   β”œβ”€β”€ checkpoint/
β”‚       β”œβ”€β”€ checkpoint_HE.pth                    
β”‚
β”œβ”€β”€ utils/                          # Core training utilities
β”‚   β”œβ”€β”€ multimodal.py               # ST_AlignmentModel & Trainer
β”‚   β”œβ”€β”€ loss.py                     
β”‚   β”œβ”€β”€ dataset_load.py           
β”‚   β”œβ”€β”€ augmentations.py           
β”‚   β”œβ”€β”€ model.py                   
β”‚   β”œβ”€β”€ optimizer.py                
β”‚   β”œβ”€β”€ scheduler.py               
β”‚   β”œβ”€β”€ gather.py                   
β”‚   └── pt_load_inference.py        
β”‚
β”œβ”€β”€ pt_dataset/                     # Pre-training datasets
β”‚   β”œβ”€β”€ st_images/                  # ST tissue images
β”‚   └── st_sentences/               # Gene sentences
β”‚
β”œβ”€β”€ ft_dataset/                     # Fine-tuning datasets
β”‚   β”œβ”€β”€ gep_pred/                   # Gene expression prediction
β”‚   β”œβ”€β”€ spatial_clustering/         # Spatial clustering (DLPFC)
β”‚   └── linear_probing/             # Linear probing benchmarks
β”‚       β”œβ”€β”€ crc
β”‚       β”œβ”€β”€ mhist
β”‚       └── luad
β”‚
β”œβ”€β”€ evaluations/                    # Evaluation scripts
β”‚   β”œβ”€β”€ gep_pred/                   # Gene expression prediction
β”‚   β”‚   β”œβ”€β”€ eval_st_conma_zeroshot.py
β”‚   β”‚   β”œβ”€β”€ train_st_conma.py
β”‚   β”‚   └── run_st_conma_*.sh
β”‚   β”œβ”€β”€ linear_probing/             # Linear probing tasks
β”‚   β”‚   β”œβ”€β”€ cam17.py
β”‚   β”‚   β”œβ”€β”€ crcnorm.py
β”‚   β”‚   β”œβ”€β”€ luad.py
β”‚   β”‚   └── mhist.py
β”‚   β”œβ”€β”€ spatial_clustering/         # Spatial domain identification
β”‚   β”œβ”€β”€ st_linear_probing/          # ST-specific linear probing
β”‚   └── cluster_plot/               # Visualization utilities
β”‚
β”œβ”€β”€ checkpoints/                    # Saved model weights
└── results/                        # Evaluation results

🌏 Environment Setup

Two conda environments are required:

conda env create -f st_conma_env.yml
conda activate st_conma
pip install --no-deps --extra-index-url https://download.pytorch.org/whl/cu124 -r st_conma_pip.txt

# For spatial clustering with STAIG module
conda env create -f st_conma_clustering_env.yml
conda activate st_conma_clustering
pip install --no-deps -f https://data.pyg.org/whl/torch-2.2.0+cu121.html -r st_conma_clustering_pip.txt

πŸš€ Dataset Preparation

1. Download Pre-training and downstream datasets

We have uploaded pre-training, downstream datasets and result files on Google Drive. Access requests will be approved as quickly as possible.

Histopathology benchmark datasets can be downloaded from the links mentioned previously.


Pre-training

conda activate st_conma
bash run_train_multitask.sh

Evaluation

Note: Adjust the CUDA device in each script as needed.

K-means Clustering on Histopathology Benchmarks

conda activate st_conma
python ./evaluations/cluster_plot/cluster_plot_st_conma.py

Linear Probing on Histopathology Benchmarks

conda activate st_conma
python ./evaluations/linear_probing/cam17.py
python ./evaluations/linear_probing/crcnorm.py
python ./evaluations/linear_probing/luad.py
python ./evaluations/linear_probing/mhist.py

Gene Expression Prediction

Evaluated on HER2ST, cSCC, and HLT datasets.

conda activate st_conma
bash ./evaluations/gep_pred/run_st_conma_igc_igm.sh
bash ./evaluations/gep_pred/run_st_conma_zeroshot.sh

For visualization, run all cells in:

  • ./evaluations/gep_pred/CD24_viz.ipynb
  • ./evaluations/gep_pred/LGALS1_viz.ipynb

Linear Probing on DLPFC Dataset

conda activate st_conma
python ./evaluations/st_linear_probing/train_st_conma_ie_dlpfc.py
python ./evaluations/st_linear_probing/train_st_conma_ge_dlpfc.py
python ./evaluations/st_linear_probing/train_st_conma_fe_dlpfc.py

Spatial Clustering

Evaluated on DLPFC and Human Breast Cancer datasets.

# Fine-tuning
conda activate st_conma
bash ./evaluations/spatial_clustering/run_finetune_dlpfc.sh
bash ./evaluations/spatial_clustering/run_finetune_hbc.sh

# Extract fusion embeddings
bash ./evaluations/spatial_clustering/run_get_fusion_embeddings_dlpfc.sh
bash ./evaluations/spatial_clustering/run_get_fusion_embeddings_hbc.sh

# Clustering with STAIG module
conda activate st_conma_clustering
python ./evaluations/spatial_clustering/train_st_conma.py \
    --dataset dlpfc --all \
    --output_dir ./results/spatial_clustering/st_conma/dlpfc

python ./evaluations/spatial_clustering/train_st_conma.py \
    --dataset human_breast_cancer --all \
    --output_dir ./results/spatial_clustering/st_conma/human_breast_cancer

Human Breast Cancer Analysis

conda activate st_conma and run all cells in ./evaluations/spatial_clustering/spatial_clustering.ipynb.