LLM-Derived Gene Semantic Embeddings Enable Spatiotemporal Functional Mapping of Mouse Embryonic Development
This repository contains the code and analysis pipeline for the paper "LLM-Derived Gene Semantic Embeddings Enable Spatiotemporal Functional Mapping of Mouse Embryonic Development". The study proposes a knowledge-driven computational framework that leverages large language model (LLM) embeddings to map the spatiotemporal functional organization of mouse embryonic development from spatial transcriptomics data.
- Python 3.9+
- Install dependencies:
pip install -r requirements.txt - R packages (for GO enrichment analysis):
ClusterProfiler,org.Mm.eg.db
The spatial transcriptomics data used in this study is from:
Zhong et al., A single-cell Stereo-seq transcriptomic atlas of mouse organogenesis, 2023.
Raw data files are not included in this repository due to size (~5GB+). To reproduce the analysis, you need to obtain:
- Expression matrices (per timepoint, 2000 HVGs): Place CSV files in
data/expression_matrices/asE9.5_matrix.csv...E16.5_matrix.csv. - Gene descriptions: Download gene functional description texts and save as
data/gene_descriptions.json. - LLM embeddings: Generate 2048-D embeddings using Qwen Embedding-v4 and save as
data/gene_embeddings_2048.json. - Full h5ad file (~7.3GB): Obtain from the original Stereo-seq data source.
NC-code/
├── README.md
├── requirements.txt
├── src/ # Analysis scripts
│ ├── pipeline.py # Gene2Role pipeline orchestrator
│ ├── spearman.py # Spearman correlation → signed edgelist
│ ├── eeisp.py # EEISP edge inference
│ ├── split_cells.py # Split expression matrix by cell type
│ ├── merge_edgelist.py # Merge multiple edgelists
│ ├── core50run.py # Core50 batch embedding runner
│ ├── run_embedding_generation.py # Embedding generation wrapper
│ ├── run-14.5-16.5.py # Cosine similarity & embedding analysis
│ └── submit_gene2role.sh # HPC job submission script
├── notebooks/ # Jupyter analysis notebooks (in order)
│ ├── 00_generate_expression_matrices.ipynb
│ ├── 01_data_preprocessing.ipynb
│ ├── 02_generate_topological_embeddings.ipynb
│ ├── 03_community_detection.ipynb
│ ├── 04_spatiotemporal_analysis.ipynb
│ └── 05_gene2role_embedding.ipynb
├── figures/ # Paper figures
│ ├── fig1.png ~ fig11.png
│ └── supplementary/fig8.jpg
├── results/ # Analysis output CSVs
│ ├── communities_for_analysis.csv
│ ├── communities_for_analysis_FIXED.csv
│ ├── module_sizes.csv
│ ├── cdf_plot_data.csv
│ ├── community_topological_evolution_distance.csv
│ └── gene2role_rankings/ # Per-timepoint gene centrality rankings
├── tools/
│ └── SignedS2V/ # Signed network embedding tool
│ ├── README.md
│ └── src/
└── data/ # (gitignored) Raw data, see Data Sources
-
Embedding Generation (
notebooks/00-02): Generate 2048-D gene embeddings using Qwen LLM, compute cosine similarity, construct gene functional network. -
Network Construction & Module Detection (
notebooks/03): Optimize similarity threshold (0.76), detect communities via hybrid strategy (connected components + Leiden), annotate with GO enrichment. -
Spatial Reconstruction (
notebooks/04): Score cells across 92 functional modules, perform Leiden clustering on functional score vectors, map back to physical coordinates. -
Stability Analysis (
notebooks/04): Jaccard index tracking across resolution parameters to recapitulate developmental hierarchy. -
Temporal Network Analysis (
notebooks/05): Gene2Role signed network embedding on liver-specific modules to track hub switching and dynamic turnover.
If you use this code, please cite our paper:
@article{llmspatioemb2026,
title={LLM-Derived Gene Semantic Embeddings Enable Spatiotemporal Functional Mapping of Mouse Embryonic Development},
author={Anonymized for review}, % TODO: restore author list before publication
year={2026}
}
This code is provided for academic research purposes.