Hist2Cell is a Vision Graph-Transformer framework that predicts fine-grained cell type abundances directly from histology images, enabling cost-efficient, high-resolution cellular mapping of tissues.
Predicting cellular compositions from histology images using deep learning
Hist2Cell is a computational framework for spatial biology analysis. Instead of requiring expensive spatial transcriptomics sequencing, our framework can predict cellular compositions directly from standard histology images.
- π° Cost-Effective: Eliminates need for expensive spatial sequencing
- π¬ High Resolution: Achieves finer spatial detail than traditional methods
- β‘ Fast Analysis: Real-time prediction from histology images
- π Broad Applicability: Works across different tissue types and diseases
Hist2Cell combines three established AI approaches:
- πΌοΈ Computer Vision (ResNet18): Analyzes tissue morphology from histology images
- πΈοΈ Graph Neural Networks (GAT): Models spatial relationships between tissue regions
- π Vision Transformers: Captures global tissue context and patterns
- Operating System: Ubuntu 22.04.4 LTS (recommended) or similar Linux distribution
- Hardware: GPU with 8GB+ VRAM (16GB+ recommended)
- Python: 3.11
- CUDA: Compatible GPU with CUDA support
# Create a new conda environment
conda create -n Hist2Cell python=3.11
conda activate Hist2Cell
git clone https://github.com/Weiqin-Zhao/Hist2Cell.git
cd Hist2Cell
# Install basic requirements
pip install -r requirements.txt
# Install PyTorch with CUDA support
pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118
# Install PyTorch Geometric
pip install torch_geometric
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.0.0+cu118.html
python -c "import torch; print('CUDA available:', torch.cuda.is_available())"
We provide a complete learning ecosystem with step-by-step tutorials designed for different skill levels and use cases.
graph TD
A[π Start Here: Read README] --> B[π§ Environment Setup]
B --> C[π Data Preparation Tutorial]
C --> D[π§ Understanding Hist2Cell Architecture]
D --> E[π Choose Your Path]
E --> F[π¬ Research Path]
E --> G[π» Development Path]
F --> I[π¨ Visualization Tutorials]
G --> J[π Training Tutorial]
Tutorial | Purpose | Skill Level | Time Required | Key Outcomes |
---|---|---|---|---|
π§ Data Preparation | Learn to process your own spatial transcriptomics data | Beginner | 1-2 hours | Understand data pipeline, prepare custom datasets |
π Model Training | Train Hist2Cell on your own data | Intermediate | 2-4 hours | Custom model training, hyperparameter tuning |
π¨ Cell Abundance Visualization | Create publication-quality spatial plots | Beginner | 30-60 min | Generate visualization of cell distributions |
πΈοΈ Cell Colocalization Analysis | Analyze spatial relationships between cell types | Advanced | 1-2 hours | Spatial statistics, colocalization patterns |
π Super-Resolution Prediction | Generate enhanced resolution cell maps | Advanced | 1-2 hours | 2Γ resolution enhancement |
Hist2Cell/
βββ π tutorial_data_preparation/ # Data processing tutorials
β βββ data_preparation_tutorial.ipynb # Complete data pipeline guide
βββ π tutorial_training/ # Model training resources
β βββ training_tutorial.ipynb # Comprehensive training guide
βββ π tutorial_analysis_evaluation/ # Analysis and evaluation tutorials
β βββ cell_abundance_visulization_tutorial.ipynb # Spatial visualization
β βββ cell_colocalization_tutorial.ipynb # Spatial relationships
β βββ super_resovled_cell_abundance_tutorial.ipynb # Super-resolution analysis
βββ π model_weights/ # Pre-trained model checkpoints
βββ π example_data/ # Example datasets and demonstrations
β βββ humanlung_cell2location/ # Standard resolution data
β βββ humanlung_cell2location_2x/ # Super-resolution data
β βββ example_raw_data/ # Raw data examples
βββ π model/ # Core model architecture
βββ π requirements.txt # Python dependencies
βββ π README.md # This comprehensive guide
Dataset | Tissue Type | Use Case | Availability | Tutorial Coverage |
---|---|---|---|---|
Human Lung | Healthy lung tissue | Primary examples, tutorials | β Provided | All tutorials |
HER2ST | Breast cancer | Disease applications | π External | Advanced usage |
STNet | Various tissues | Method validation | π External | Custom training |
TCGA | Cancer samples | Clinical applications | π External | Research projects |
HEST-1k | Multiple organs | Large-scale analysis | π External | Scalability studies |
We provide processed example data for tutorials and demonstrations. The original datasets are from the published sources listed above, but we've prepared processed versions for direct use with Hist2Cell.
# Download processed data from our OneDrive link
# Visit: example_data/README.md for the download link
# After downloading, unzip the data using:
tar -xzvf [downloaded_file.tar.gz]
# Verify example data structure
ls example_data/
# Should show: humanlung_cell2location/, humanlung_cell2location_2x/, example_raw_data/
We provide:
- Processed example data of the healthy lung dataset in
./example_data/humanlung_cell2location
- Super-resolved cell abundance data in
./example_data/humanlung_cell2location_2x
- Example raw data in
./example_data/example_raw_data
For users who want to process their own datasets, we provide detailed tutorials in ./tutorial_data_preparation/data_preparation_tutorial.ipynb
.
Want to see Hist2Cell in action immediately? Run this quick demonstration:
# Navigate to visualization tutorial
cd tutorial_analysis_evaluation/
# Launch Jupyter notebook
jupyter notebook cell_abundance_visulization_tutorial.ipynb
# Follow the step-by-step guide to generate your first spatial cell map!
This will generate publication-quality visualizations in under an hour.
If you use Hist2Cell in your research, please cite our work:
@article{zhao2024hist2cell,
title={Hist2Cell: Deciphering Fine-grained Cellular Architectures from Histology Images},
author={Zhao, Weiqin and Liang, Zhuo and Huang, Xianjie and Huang, Yuanhua and Yu, Lequan},
journal={bioRxiv},
pages={2024--02},
year={2024},
publisher={Cold Spring Harbor Laboratory}
}
This project is licensed under the MIT License - see the LICENSE file for details.
- π« Institutions: University collaborations and support
- π° Funding: Grant agencies and foundations
- π₯ Community: Contributors and early adopters
- π¬ Datasets: Original data providers and consortiums
Ready to enhance your tissue analysis?
π Read the Paper β’ π Tutorials
Supporting spatial biology research through computational methods