Skip to content

Repository files navigation

[ICML 2026] MoLF: Mixture-of-Latent-Flow

Pan-Cancer Spatial Gene Expression Prediction from Histology

[πŸ“„ 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.

πŸ’‘ Key Highlights

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

πŸ› οΈ Framework

  1. Latent Compression: A Transformer-VAE compresses high-dimensional gene expression into a structured manifold.
  2. Generative Flow: A Conditional Flow Matching model, parameterized by an MoE velocity field, generates expressions conditioned on H&E patches.

MoLF Overview

Folder Structure

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/

Folder descriptions

  • 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).

Quick Start

0.0 Data Preprocessing

  • Download HEST1k from huggingface https://huggingface.co/datasets/MahmoodLab/hest. to data/HEST1K or [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/univ2 with names [sample_id]_embeddings.pt which contains barcodes and correspongding uni features. This path is referred in utils/custom_dataset.py for 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_0 and data/Hest_Bench/hest_pathway_clean_split_1.

Following code could be used to preprocecss HEST1k dataset.

python3 utils/pfm_preprocesing.py

1.0 Trianing

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

2.0 Sampling

# 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

3.0 Post-hoc analysis & visualization

3.1 Gene VAE latent visualization

python3 gene_autoencoder_latent_visulization.py -l gene_vae/gene_vae_w_hvg_clean_split_0

3.3 Latent flow trajectory analysis

add flag with chosen cfg scale from previous step

python3 post_training_trajectory_analysis.py -l training_log/MoLF_split_0 -g 3.0

3.3 Plot experts analysis

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

License

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.

πŸ“ Citation

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}
}

About

[ICML2026] MoLF (Mixture-of-Latent-Flow): Pan-Cancer Spatial Gene Expression Prediction from Histology

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages