[π Paper] [π Project Page] [π» Code]
MoLF is a generative framework for scalable pan-cancer histogenomics. It utilizes a Mixture-of-Experts (MoE) velocity field within a conditional Flow Matching framework to predict spatial gene expression directly from standard H&E histology.
- State-of-the-Art: Outperforms existing methods on the HEST-1k pan-cancer benchmark.
- Scalable Architecture: Decouples diverse tissue patterns by routing morphological features through specialized experts.
-
Zero-Shot Generalization: Demonstrates robust cross-species transfer (Human
$\rightarrow$ Mouse) by learning invariant biological motifs. - Optimal Transport: Efficiently maps random noise to a structured latent gene manifold in a single ODE step.
π‘ Need low-compute, high-throughput precision for routine diagnostics? Check out our sister project, HistoPrism(ICLR 2026). While MoLF is built for exploratory robustness across diverse datasets, HistoPrism is highly optimized to deliver peak in-distribution accuracy for standardized human tissue screening and biomarker discovery.
- Latent Compression: A Transformer-VAE compresses high-dimensional gene expression into a structured manifold.
- Generative Flow: A Conditional Flow Matching model, parameterized by an MoE velocity field, generates expressions conditioned on H&E patches.
Project top-level layout:
.
ββ gene_autoencoder_latent_visulization.py
ββ gene_autoencoder_train.py
ββ index.html
ββ LICENSE
ββ post_training_experts_analysis.py
ββ post_training_trajectory_analysis.py
ββ README.MD
ββ sampling.py
ββ train.py
ββ configs/
β ββ autoencoder_config_local.yml
β ββ autoencoder_config.yml
β ββ training_config_latent_moe_local.yml
β ββ training_config_latent_moe.yml
ββ data/
β ββ Hallmark/
β ββ Hest_Bench/
β ββ sample_processed_HEST1K/
ββ figures/
ββ gene_vae/
β ββ ...
ββ models/
ββ training_log/
ββutils/
configs/: Configuration YAML files for VAE and flow training.data/: Preprocessed datasets (HEST1k, Hest_Bench, Hallmark gene sets) and split lists.figures/: Generated figures, overview diagrams, and assets used in the README/paper.gene_vae/: Outputs from gene VAE training (configs, checkpoints, UMAP embeddings and reducers).models/: Model definitions, baseline implementations, and architecture utilities.training_log/: Training run outputs and checkpoints, sampling/trajectory subfolders, and run configs.utils/: Helper modules for data loading, preprocessing, training utilities, and analysis tools.- Top-level scripts:
train.py(flow training),gene_autoencoder_train.py(VAE training),sampling.py(generate samples),post_training_*scripts (analysis & visualization).
- Download HEST1k from huggingface https://huggingface.co/datasets/MahmoodLab/hest. to
data/HEST1Kor [PATH/TO/YOUR/HEST1K] - Please follow respective pathology foundation model (PFM) repositories for preprocessing. For example, preprocessed data with PFM uni_v2 is in
data/sample_processed_HEST1K/univ2with names[sample_id]_embeddings.ptwhich contains barcodes and correspongding uni features. This path is referred inutils/custom_dataset.pyfor dataloading. - Also download hest_bench https://huggingface.co/datasets/MahmoodLab/hest-bench and put it in
data/Hest_Bench[PATH/TO/YOUR/hest_bench] for fixed held-out test set and HVG-50 genes list - Data split is merged from hest-bench and provided in
data/Hest_Bench/hest_pathway_clean_split_0anddata/Hest_Bench/hest_pathway_clean_split_1.
Following code could be used to preprocecss HEST1k dataset.
python3 utils/pfm_preprocesing.py
- Stage 1 gene VAE
python3 gene_autoencoder_train.py -f configs/training_config_latent_moe.yml
- stage 2 latent flow matching
python3 train.py -f configs/training_config_latent_moe.yml
Pretrained weights can also be downloaded from huggingface.
# test set sampling
python3 sampling.py -l training_log/run_20260506_162107_molf -g 2.0
# external mouse validation sampling
python3 sampling.py -l training_log/run_20260506_162107_molf -g 2.0 -e
python3 gene_autoencoder_latent_visulization.py -l gene_vae/gene_vae_w_hvg_clean_split_0
add flag with chosen cfg scale from previous step
python3 post_training_trajectory_analysis.py -l training_log/MoLF_split_0 -g 3.0
Given sampling dir, to plot experts utilization.
python3 post_training_experts_analysis.py -s training_log/MoLF_split_0/sampling_2euler_cfg_guidance_3.0_epoch158 -t training_log/MoLF_split_0/trajectory_2euler_cfg_guidance_3.0_epoch158
This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0). For full details, see the LICENSE file.
If you find our work useful, please consider cite us.
@inproceedings{hu2026molf,
author = {Hu, Susu and Speidel, Stefanie},
title = {MoLF: Mixture-of-Latent-Flow for Pan-Cancer Spatial Gene Expression Prediction from Histology},
booktitle = {Proceedings of the 43rd International Conference on Machine Learning (ICML)},
year = {2026},
url = {https://icml.cc/virtual/2026/poster/63940}
}