GRAIL-Heart: Graph-based Reconstruction of Artificial Intercellular Links
A Graph Neural Network framework for analyzing cell-cell communication in cardiac spatial transcriptomics data, featuring both forward and inverse modelling capabilities.
Explore ligand-receptor interaction networks across all six cardiac regions with our interactive web application.
Overview
GRAIL-Heart is a deep learning model designed to discover and analyze ligand-receptor (L-R) interactions in spatial transcriptomics datasets, with a focus on cardiac tissue. The framework integrates:
Gene expression encoding with neural networks
Spatial information through positional embeddings
Graph attention mechanisms for neighborhood analysis
Multi-task learning for simultaneous prediction of L-R interactions, gene expression reconstruction, and cell type classification
Inverse modelling for inferring causal L-R signals that drive cell differentiation
Forward vs Inverse Modelling
Modelling Type
Input
Output
Question Answered
Forward
Expression + Spatial
L-R predictions
"Which L-R interactions are active?"
Inverse
Observed phenotype
Causal L-R signals
"What signals drove this differentiation?"
The model is trained on the Heart Cell Atlas v2, comprising spatial transcriptomics data from six distinct cardiac regions (Apex, Left Atrium, Left Ventricle, Right Atrium, Right Ventricle, and Septum).
Key Features
Multi-task learning framework balancing L-R prediction, reconstruction, and classification
Edge-type aware Graph Attention Networks with spatial and L-R edge types
1# Run prediction2grail-heart predict my_data.h5ad --output results.csv
34# Run inverse modeling5grail-heart predict my_data.h5ad --mode inverse --output causal_results.csv
67# Show model info8grail-heart info
910# Start web application11grail-heart app
Web Application
Start the interactive web app for uploading and analyzing your own data:
bash
1# Option 1: Using CLI2grail-heart app
34# Option 2: Using Streamlit directly5streamlit run app/app.py
Given gene expression data from cardiac cells, the model predicts which ligand-receptor interactions are active. This uses:
Graph neural networks to capture spatial context
Multi-head attention over cell neighborhoods
Expression correlation with curated L-R databases
Inverse Modeling
Observed Fates → Causal L-R Signals
The key innovation of GRAIL-Heart. Given observed cell differentiation patterns, the model identifies which L-R interactions are causally responsible for driving those fates. This:
Goes beyond simple expression correlation
Identifies mechanosensitive pathways
Links molecular signaling to tissue patterning
Key dependencies:
PyTorch 2.0+
PyTorch Geometric
OmniPath (L-R database access)
Scanpy (single-cell analysis)
AnnData (data container)
Pandas, NumPy
Matplotlib, Seaborn (visualization)
PyYAML (configuration)
TensorBoard (logging)
Data Preparation
Download Heart Cell Atlas v2
Download the Visium spatial transcriptomics files from the Heart Cell Atlas:
adata.obs: Cell metadata (including cell types if available)
adata.var: Gene names and features
The framework will automatically:
Select top 2,000 highly variable genes
Normalize library sizes
Apply log1p transformation
Filter cells (min 200 genes) and genes (min 3 cells)
Usage
Training (Forward + Inverse Modelling)
Training jointly optimizes both forward modelling (expression to L-R predictions) and inverse modelling (inferring causal L-R signals that drive cell fates). By default, inverse modelling is enabled.
Standard Training:
python train.py --config configs/default.yaml
Cross-Validation (Recommended):
Run Leave-One-Region-Out cross-validation for robust evaluation:
bash
1# Full 6-fold CV with inverse modelling2python train_cv.py --config configs/cv.yaml
34# Quick test (specific folds, fewer epochs)5python train_cv.py --config configs/cv.yaml --n_epochs 50 --folds "AX,LA,LV"67# Run specific regions only8python train_cv.py --config configs/cv.yaml --folds "RV,SP"
Standard Training
Train the GRAIL-Heart model with default configuration:
Reduce model hidden dimension or number of GAT layers
Missing Data Files
Ensure all required .h5ad files are in data/HeartCellAtlasv2/ directory with correct naming:
visium-OCT_AX_raw.h5ad
visium-OCT_LA_raw.h5ad
visium-OCT_LV_raw.h5ad
visium-OCT_RA_raw.h5ad
visium-OCT_RV_raw.h5ad
visium-OCT_SP_raw.h5ad
CUDA Errors
If CUDA is not detected:
bash
1# Verify CUDA installation2python -c "import torch; print(torch.cuda.is_available())"34# Force CPU training (slower)5# Edit configs/cv.yaml: hardware.device: cpu