Data availabilityData supporting the findings of this work are available within the article and its Supplementary Information. All the Stereo-seq data of GAC samples have been deposited in public databases. The raw sequencing data have been deposited at the Genome Sequence Archive for humans (GSA-Human, https://ngdc.cncb.ac.cn/gsa-human/) with the accession number HRA009001. Access to human sequencing data is controlled because the data are derived from human participants, and can be requested through the GSA-Human data access committee according to its policies. CosMx human liver data are available at https://brukerspatialbiology.com/products/cosmx-spatial-molecular-imager/ffpe-dataset/human-liver-rna-ffpe-dataset/. The BIDCell dataset with transcriptomics and cytological images (Xenium breast data) is available via GitHub at https://github.com/SydneyBioX/BIDCell/tree/main/data. The SCS dataset with transcriptomics and cytological images (Stereo-seq data) is available via GitHub at https://github.com/chenhcs/SCS/tree/main/data. The SPATCH benchmark dataset is available at https://spatch.pku-genomics.org. The RNA-seq datasets for pan-cancer were downloaded from the GEO database under accession codes GSE142213, GSE132509, GSE154109, GSE116256, GSE141526, GSE149652, GSE110686, GSE114727, GSE139495, GSE138709, GSE142784, GSE111014, GSE125881, GSE132065, GSE142744, GSE136394, GSE137829, GSE103224, GSE131928, GSE141982, GSE103322, GSE139324, GSE111360, GSE121636, GSE139555, GSE98638, GSE117156, GSE128531, GSE147944, GSE150430, GSE117570, GSE127465, GSE131907, GSE143423, GSE153935, GSE115007, GSE130000, GSE154600, GSE111672, GSE141017, GSE154778, GSE151310, GSE141445, GSE144236, GSE145328, GSE123139, GSE139249, GSE148190, GSE72056, GSE134520 and GSE139829. Source data are provided with this paper.Code availabilityThe source code of DISSECT is publicly available under the MIT License via GitHub at https://github.com/zenglab-pku/DISSECT and via Zenodo at https://doi.org/10.5281/zenodo.20584304 (ref. 69). The following Python packages were used to build DISSECT and analyze the data: anndata v.0.10.3, detectron2 v.0.6, matplotlib v.3.7.2, numpy v.1.26.4, pandas v.2.2.3, scanpy v.1.10.1, scikit-learn v.1.2.2, scikit-image v.0.19.3, scipy v.1.10.1, torch v.2.2.0 with CUDA 11.8, torchdata v.0.7.1, torchgeometry v.0.1.2 and torchvision v.0.17.0+cu118. Stereo-seq FASTQ data were processed using SAW v.7.1/Docker tag 07.1.2. Spatial transcriptomic analyses used Scanpy v.1.10.1, Squidpy v.1.6.5, stLearn v.1.3.2, STAGATE_pyG v.1.0.0 and CellTypist v.1.7.1. Gene set enrichment analysis was performed using GSEApy v.1.1.3. Visualization and statistical analyses used ComplexHeatmap v.2.18.0, pheatmap v.1.0.12, Circos v.0.69.9 and ggcor downloaded from GitHub in June 2026. Cell–cell communication analyses used CellChat v.1.1.0 and CellPhoneDB v.4.0.0. For benchmarking, DeepCell/Mesmer v.0.12.7, Cellpose27,28 v.2.2.2, StarDist33,34,35 v.0.8.5, SCS30 downloaded from GitHub in March 2024 and BIDCell32 v.1.0.3 were used.ReferencesChen, A. et al. Spatiotemporal transcriptomic atlas of mouse organogenesis using DNA nanoball-patterned arrays. Cell 185, 1777–1792 (2022).Article Google Scholar Cho, C. S. et al. Microscopic examination of spatial transcriptome using Seq-Scope. Cell 184, 3559–3572 (2021).Article Google Scholar Fu, X. et al. Polony gels enable amplifiable DNA stamping and spatial transcriptomics of chronic pain. Cell 185, 4621–4633 (2022).Article Google Scholar He, S. et al. High-plex imaging of RNA and proteins at subcellular resolution in fixed tissue by spatial molecular imaging. Nat. Biotechnol. 40, 1794–1806 (2022).Article Google Scholar Rao, A., Barkley, D., Franca, G. S. & Yanai, I. Exploring tissue architecture using spatial transcriptomics. Nature 596, 211–220 (2021).Article Google Scholar Li, X. & Wang, C. Y. From bulk, single-cell to spatial RNA sequencing. Int. J. Oral Sci. 13, 36 (2021).Article Google Scholar Lubeck, E., Coskun, A. F., Zhiyentayev, T., Ahmad, M. & Cai, L. Single-cell in situ RNA profiling by sequential hybridization. Nat. Methods 11, 360–361 (2014).Article Google Scholar Chen, K. H., Boettiger, A. N., Moffitt, J. R., Wang, S. & Zhuang, X. RNA imaging. Spatially resolved, highly multiplexed RNA profiling in single cells. Science 348, aaa6090 (2015).Article Google Scholar Janesick, A. et al. High resolution mapping of the tumor microenvironment using integrated single-cell, spatial and in situ analysis. Nat. Commun. 14, 8353 (2023).Article Google Scholar Bressan, D., Battistoni, G. & Hannon, G. J. The dawn of spatial omics. Science 381, eabq4964 (2023).Article Google Scholar Tian, L., Chen, F. & Macosko, E. Z. The expanding vistas of spatial transcriptomics. Nat. Biotechnol. 41, 773–782 (2023).Williams, C. G., Lee, H. J., Asatsuma, T., Vento-Tormo, R. & Haque, A. An introduction to spatial transcriptomics for biomedical research. Genome Med. 14, 68 (2022).Article Google Scholar Oliveira, M. F. et al. Characterization of immune cell populations in the tumor microenvironment of colorectal cancer using high definition spatial profiling. Preprint at bioRxiv https://doi.org/10.1101/2024.06.04.597233 (2024).Zeng, Z., Li, Y., Li, Y. & Luo, Y. Statistical and machine learning methods for spatially resolved transcriptomics data analysis. Genome Biol. 23, 83 (2022).Article Google Scholar Minaee, S. et al. Image segmentation using deep learning: a survey. IEEE Trans. Pattern Anal. Mach. Intell. 44, 3523–3542 (2021).Google Scholar Girshick, R., Donahue, J., Darrell, T. & Malik, J. Rich feature hierarchies for accurate object detection and semantic segmentation. In Proc. IEEE Conference on Computer Vision and Pattern Recognition 580–587 (IEEE, 2014).Girshick, R. Fast R-CNN. In Proc. IEEE International Conference on Computer Vision 1440–1448 (IEEE, 2015).Ren, S., He, K., Girshick, R. & Sun, J. Faster R-CNN: towards real-time object detection with region proposal networks. Adv. Neural Inf. Process. Syst. 28, 91–99 (2015).Google Scholar He, K., Gkioxari, G., Dollár, P. & Girshick, R. Mask R-CNN. In Proc. IEEE International Conference on Computer Vision 2961–2969 (IEEE, 2017).Tian, Z., Shen, C. & Chen, H. Conditional convolutions for instance segmentation. In Proc. European Conf. Computer Vision 282–298 (Springer, 2020).Sun, P. et al. Sparse R-CNN: End-to-end object detection with learnable proposals. In Proc. IEEE/CVF Conference on Computer Vision and Pattern Recognition 14454–14463 (IEEE/CVF, 2021).Carion, N. et al. End-to-end object detection with transformers. In Proc. European Conference on Computer Vision 213–229 (Springer, 2020).Kirillov, A. et al. Segment anything. In Proc. IEEE/CVF International Conference on Computer Vision 4015–4026 (IEEE/CVF, 2023).Huang, Y. et al. Segment anything model for medical images?. Med. Image Anal. 92, 103061 (2024).Article Google Scholar Mandal, S. & Uhlmann, V. SplineDist: automated cell segmentation with spline curves. In Proc. 2021 IEEE 18th International Symposium on Biomedical Imaging 1082–1086 (IEEE, 2021).Petukhov, V. et al. Cell segmentation in imaging-based spatial transcriptomics. Nat. Biotechnol. 40, 345–354 (2022).Article Google Scholar Stringer, C., Wang, T., Michaelos, M. & Pachitariu, M. Cellpose: a generalist algorithm for cellular segmentation. Nat. Methods 18, 100–106 (2021).Article Google Scholar Pachitariu, M. & Stringer, C. Cellpose 2.0: how to train your own model. Nat. Methods 19, 1634–1641 (2022).Article Google Scholar Greenwald, N. F. et al. Whole-cell segmentation of tissue images with human-level performance using large-scale data annotation and deep learning. Nat. Biotechnol. 40, 555–565 (2022).Article Google Scholar Chen, H., Li, D. & Bar-Joseph, Z. SCS: cell segmentation for high-resolution spatial transcriptomics. Nat. Methods 20, 1237–1243 (2023).Article Google Scholar Griebel, M. et al. Deep learning-enabled segmentation of ambiguous bioimages with deepflash2. Nat. Commun. 14, 1679 (2023).Article Google Scholar Fu, X. et al. BIDCell: biologically-informed self-supervised learning for segmentation of subcellular spatial transcriptomics data. Nat. Commun. 15, 509 (2024).Article Google Scholar Schmidt, U., Weigert, M., Broaddus, C. & Myers, G. Cell detection with star-convex polygons. In Proc. Medical Image Computing and Computer Assisted Intervention 265–273 (Springer, 2018).Weigert, M., Schmidt, U., Haase, R., Sugawara, K. & Myers, G. Star-convex polyhedra for 3D object detection and segmentation in microscopy. In Proc. IEEE/CVF Winter Conference on Applications of Computer Vision 3666–3673 (IEEE/CVF, 2020).Weigert, M. & Schmidt, U. Nuclei instance segmentation and classification in histopathology images with StarDist. In Proc. 2022 IEEE International Symposium on Biomedical Imaging Challenges 1–4 (IEEE, 2022).Smyth, E. C., Nilsson, M., Grabsch, H. I., van Grieken, N. C. & Lordick, F. Gastric cancer. Lancet 396, 635–648 (2020).Article Google Scholar In, H. et al. Validation of the 8th Edition of the AJCC TNM Staging System for Gastric Cancer using the National Cancer Database. Ann. Surg. Oncol. 24, 3683–3691 (2017).Article Google Scholar Kang, Y. K. et al. Nivolumab in patients with advanced gastric or gastro-oesophageal junction cancer refractory to, or intolerant of, at least two previous chemotherapy regimens (ONO-4538-12, ATTRACTION-2): a randomised, double-blind, placebo-controlled, phase 3 trial. Lancet 390, 2461–2471 (2017).Article Google Scholar Fuchs, C. S. et al. Safety and efficacy of pembrolizumab monotherapy in patients with previously treated advanced gastric and gastroesophageal junction cancer: phase 2 clinical KEYNOTE-059 Trial. JAMA Oncol. 4, e180013 (2018).Article Google Scholar Janjigian, Y. Y. et al. First-line nivolumab plus chemotherapy versus chemotherapy alone for advanced gastric, gastro-oesophageal junction, and oesophageal adenocarcinoma (CheckMate 649): a randomised, open-label, phase 3 trial. Lancet 398, 27–40 (2021).Article Google Scholar Zeng, Z. et al. Machine learning on syngeneic mouse tumor profiles to model clinical immunotherapy response. Sci. Adv. 8, eabm8564 (2022).Article Google Scholar Yeoh, K. G. & Tan, P. Mapping the genomic diaspora of gastric cancer. Nat. Rev. Cancer 22, 71–84 (2022).Article Google Scholar Sathe, A. et al. Single-cell genomic characterization reveals the cellular reprogramming of the gastric tumor microenvironment. Clin. Cancer Res. 26, 2640–2653 (2020).Article Google Scholar Kang, B. et al. Parallel single-cell and bulk transcriptome analyses reveal key features of the gastric tumor microenvironment. Genome Biol. 23, 265 (2022).Article Google Scholar Kumar, V. et al. Single-cell atlas of lineage states, tumor microenvironment, and subtype-specific expression programs in gastric cancer. Cancer Discov. 12, 670–691 (2022).Article Google Scholar Li, X. et al. Single-cell RNA sequencing reveals a pro-invasive cancer-associated fibroblast subgroup associated with poor clinical outcomes in patients with gastric cancer. Theranostics 12, 620–638 (2022).Article Google Scholar Zhang, P. et al. Dissecting the single-cell transcriptome network underlying gastric premalignant lesions and early gastric cancer. Cell Rep. 27, 1934–1947 (2019).Article Google Scholar Van Valen, D. A. et al. Deep learning automates the quantitative analysis of individual cells in live-cell imaging experiments. PLoS Comput. Biol. 12, e1005177 (2016).Article Google Scholar Ren, P. et al. Systematic benchmarking of high-throughput subcellular spatial transcriptomics platforms across human tumors. Nat. Commun. 16, 9232 (2025).Article Google Scholar Li, M. et al. CellBin: a highly accurate single-cell gene expression processing pipeline for high-resolution spatial transcriptomics. Preprint at bioRxiv https://doi.org/10.1101/2023.02.28.530414 (2024).He, K., Zhang, X., Ren, S. & Sun, J. Deep residual learning for image recognition. In Proc. IEEE Conference on Computer Vision and Pattern Recognition 770–778 (IEEE, 2016).Liu, Z. et al. Swin transformer: hierarchical vision transformer using shifted windows. In Proc. IEEE/CVF International Conference on Computer Vision 10012–10022 (IEEE/CVF, 2021).Liu, Z. et al. Swin transformer v2: scaling up capacity and resolution. In Conference on Computer Vision and Pattern Recognition 12009–12019 (IEEE/CVF, 2022).Liu, Z. et al. A ConvNet for the 2020s. In Proc. IEEE/CVF Conference on Computer Vision and Pattern Recognition 11976–11986 (IEEE/CVF, 2022).Xu, C. et al. Automatic cell-type harmonization and integration across Human Cell Atlas datasets. Cell 186, 5876–5891 (2023).Article Google Scholar Hu, J. et al. Role of intestinal trefoil factor in protecting intestinal epithelial cells from burn-induced injury. Sci. Rep. 8, 3201 (2018).Article Google Scholar Soutto, M. et al. Loss of TFF1 is associated with activation of NF-κB-mediated inflammation and gastric neoplasia in mice and humans. J. Clin. Invest. 121, 1753–1767 (2011).Article Google Scholar Ruchaud-Sparagano, M. H., Westley, B. R. & May, F. E. The trefoil protein TFF1 is bound to MUC5AC in human gastric mucosa. Cell. Mol. Life Sci. 61, 1946–1954 (2004).Article Google Scholar Yao, K., Zhou, E., Schaafsma, E., Zhang, B. & Cheng, C. Immune checkpoint gene VSIR predicts patient prognosis in acute myeloid leukemia and myelodysplastic syndromes. Cancer Med. 12, 5590–5602 (2023).Article Google Scholar Wolf, F. A., Angerer, P. & Theis, F. J. SCANPY: large-scale single-cell gene expression data analysis. Genome Biol. 19, 15 (2018).Article Google Scholar Palla, G. et al. Squidpy: a scalable framework for spatial omics analysis. Nat. Methods 19, 171–178 (2022).Article Google Scholar Pham, D. et al. Robust mapping of spatiotemporal trajectories and cell–cell interactions in healthy and diseased tissues. Nat. Commun. 14, 7739 (2023).Article Google Scholar Dong, K. & Zhang, S. Deciphering spatial domains from spatially resolved transcriptomics with an adaptive graph attention auto-encoder. Nat. Commun. 13, 1739 (2022).Article Google Scholar Gu, Z., Eils, R. & Schlesner, M. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 32, 2847–2849 (2016).Article Google Scholar Fang, Z., Liu, X. & Peltz, G. GSEApy: a comprehensive package for performing gene set enrichment analysis in Python. Bioinformatics 39, btac757 (2023).Article Google Scholar Jin, S. et al. Inference and analysis of cell–cell communication using CellChat. Nat. Commun. 12, 1088 (2021).Article Google Scholar Efremova, M., Vento-Tormo, M., Teichmann, S. A. & Vento-Tormo, R. CellPhoneDB: inferring cell–cell communication from combined expression of multi-subunit ligand-receptor complexes. Nat. Protoc. 15, 1484–1506 (2020).Article Google Scholar Garcia-Alonso, L. et al. Single-cell roadmap of human gonadal development. Nature 607, 540–547 (2022).Article Google Scholar He, Y. et al. DISSECT (v0.5.4). Zenodo https://doi.org/10.5281/zenodo.20584304 (2026).Download referencesAcknowledgementsWe thank T. Xu and H. Zhang for their advice and discussion, and Y. Miao for laboratory support. Part of the analysis was performed at the High-Performance Computing Platform of the Center for Life Sciences (Peking University).FundingThis work was supported by the National Natural Science Foundation of China (grant nos. 92574301, 92374116 and T2321001 to Z. Zeng), the Innovative Drug Research and Development-National Science and Technology Major Project (grant no. 2025ZD1800400 to Z. Zeng), the Fundamental and Interdisciplinary Disciplines Breakthrough Plan of the Ministry of Education of China (grant no. JYB2025XDXM502 to Z. Zeng), the Beijing Advanced Center of Cellular Homeostasis and Aging-Related Diseases (to Z. Zeng), the Noncommunicable Chronic Diseases-National Science and Technology Major Project (grant no. 2024ZD0520600 to Z. Zeng) and the Peking-Tsinghua Center for Life Sciences (to Z. Zeng).Author informationAuthor notesThese authors contributed equally: Yufeng He, Yanping Zhao, Rui Zhang, Heli Yang.Authors and AffiliationsPeking-Tsinghua Center for Life Sciences, Academy for Advanced Interdisciplinary Studies, Peking University, Beijing, ChinaYufeng He, Rui Zhang, Pengfei Ren, Peng Zhang & Zexian ZengTsinghua-Peking Center for Life Sciences, School of Life Sciences, Tsinghua University, Beijing, ChinaYanping ZhaoKey Laboratory of Carcinogenesis and Translational Research (Ministry of Education/Beijing), Center of Gastrointestinal Cancer, Peking University Cancer Hospital and Institute, Beijing, ChinaHeli Yang & Zhaode BuCenter for Quantitative Biology, Academy for Advanced Interdisciplinary Studies, Peking University, Beijing, ChinaZongxu Zhang, Ce Luo & Zexian ZengDepartment of Obstetrics and Gynecology, Seventh Medical Center of Chinese PLA General Hospital, Beijing, ChinaZhe ZhangDepartment of Gastroenterological Surgery, Peking University People’s Hospital, Beijing, ChinaSen HouDepartment of Preventive Medicine, Feinberg School of Medicine, Northwestern University, Chicago, IL, USAYuan LuoTsinghua-Peking Center for Life Sciences, Department of Basic Medical Sciences, Tsinghua University, Beijing, ChinaDeng PanPeking University Chengdu Academy for Advanced Interdisciplinary Biotechnologies, Chengdu, ChinaZexian ZengAuthorsYufeng HeView author publicationsSearch author on:PubMed Google ScholarYanping ZhaoView author publicationsSearch author on:PubMed Google ScholarRui ZhangView author publicationsSearch author on:PubMed Google ScholarHeli YangView author publicationsSearch author on:PubMed Google ScholarZongxu ZhangView author publicationsSearch author on:PubMed Google ScholarPengfei RenView author publicationsSearch author on:PubMed Google ScholarCe LuoView author publicationsSearch author on:PubMed Google ScholarPeng ZhangView author publicationsSearch author on:PubMed Google ScholarZhe ZhangView author publicationsSearch author on:PubMed Google ScholarSen HouView author publicationsSearch author on:PubMed Google ScholarZhaode BuView author publicationsSearch author on:PubMed Google ScholarYuan LuoView author publicationsSearch author on:PubMed Google ScholarDeng PanView author publicationsSearch author on:PubMed Google ScholarZexian ZengView author publicationsSearch author on:PubMed Google ScholarContributionsY.H., Y.Z., Y.L. and Z. Zeng designed the model. D.P. and Z. Zeng supervised the biological findings. Y.H. and Y.Z. built and trained the model and performed benchmarking studies and bioinformatic data analysis. P.R., C.L., R.Z. and Zongxu Zhang assisted in model design and mathematical derivation. R.Z., C.L., S.H. and H.Y. performed public data collection, benchmarking studies, part of the data analysis and all biological experiments. Y.H., P.Z. and Zhe Zhang assisted in data preprocessing and data quality control. Z.B., R.Z. and H.Y. collected the surgical samples for sequencing. The paper was written by all authors and was further revised by Z. Zeng, D.P., Y.L. and Z.B. The study was supervised by Z. Zeng, D.P., Y.L. and Z.B.Corresponding authorsCorrespondence to Zhaode Bu, Yuan Luo, Deng Pan or Zexian Zeng.Ethics declarationsCompeting interestsD.P. received sponsored research funding from Bayer AG and Boehringer Ingelheim. These grants were not related to the research reported in this study. The other authors declare no competing interests.Peer reviewPeer review informationNature Computational Science thanks Dayong Jin, Qiwei Li and the other, anonymous, reviewer(s) for their contribution to the peer review of this work. Peer reviewer reports are available. Primary Handling Editors: Kaitlin McCardle and Ananya Rastogi, in collaboration with the Nature Computational Science team.Additional informationPublisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.Extended dataExtended Data Fig. 1 Backbone architectures and training configurations for DISSECT.a-c. Learning curves of total loss, time per epoch, and individual losses (cross-entropy loss, bounding box regression loss, GIoU loss, and mask loss) per epoch for models with ResNet-50 (a), ResNet-101 (b), and Swin Transformer (c) backbones. d. Box plot showing the number of detected bounding boxes during training across different batch sizes. The blue dashed line connects the mean values. e. Box plot of training time per epoch under different batch sizes. The red dashed line connects the mean values. In d and e, each box plot ranges from the first to third quartile with the median as the horizontal line. The lower whisker extends to 1.5 times the interquartile range below the first quartile, while the upper whisker extends to 1.5 times the interquartile range above the third quartile. For d and e, n = 5 computational replicates for each batch size.Source dataExtended Data Fig. 2 Benchmarking of DISSECT with multimodal cell segmentation tools and model performance analysis on the SPATCH dataset.a. Box plot comparing ground-truth and predicted cell (nucleus) counts for DISSECT, BIDCell32, and SCS30 on the SPATCH dataset49. b. Box plots of benchmarking performance of DISSECT, BIDCell32 and SCS30 using metrics including mean average precision (mAP[0.5:0.95]) (left), AP50 (middle), and AP75 (right). Evaluation was conducted using the SPATCH dataset49 profiled with the Visium HD platform. c. Visualization of segmentation results of DISSECT and SCS on the Stereo-seq dataset used in SCS (left), and segmentation results of DISSECT and BIDCell on the Xenium 1k dataset used in BIDCell (right). d. Box plots of ablation study and hyperparameter sensitivity analysis. From left to right, box plots show segmentation performance (mAP) comparing DISSECT with or without transcriptomic fine-tuning; 4-connected or 8-connected neighborhoods for gradient field computation; varying numbers of region proposals; and different diffusion sampling steps. e. Box plots of ablation study of the diffusion refinement by varying the number of DDIM sampling steps (left), the Transformer-based decoder capacity by varying the number of decoder heads (middle) and the transcriptome-guided refinement gating by comparing dynamic \(\alpha\) with fixed \(\alpha\) baselines (right). f. Violin plots showing the memory usage during DISSECT inference on the SPATCH dataset by spatial transcriptomic platforms (left) and tumor types (right). g. Box plot showing the inference runtime of DISSECT and other cell segmentation tools on the SPATCH dataset. In a, b, d, and f, each box plot ranges from the first to third quartile with the median as the horizontal line. The lower whisker extends to 1.5 times the interquartile range below the first quartile, while the upper whisker extends to 1.5 times the interquartile range above the third quartile. For a and b, n = 15 independent annotated image patches with matched spatial transcriptomic data. For d, n = 5 computational replicates for each condition. For f, n = 15 independent annotated image patches with matched spatial transcriptomic data.Source dataExtended Data Fig. 3 Characterization of cell segmentation performance on independent datasets.a. Box plots of benchmarking cell segmentation performance based on cytological image characteristics: cell area in pixels (left), cell count (middle), and cell circularity (right) on CosMx 1k dataset. b. Box plots of benchmarking cell segmentation performance based on transcriptomic characteristics: ratio of transcripts assigned to cells to total transcripts, number of genes expressed per cell (n genes by counts), and number of cells expressing each gene (n cells by counts) on CosMx 1k dataset. c. Representative visualization of segmentation results across different datasets, including the CosMx 1k dataset (top), the Xenium 1k dataset (middle), and the Stereo-seq dataset (bottom). For a, cell area and circularity were calculated at the cell level, with n = 89,851 cells for Cellpose, 260,998 cells for DISSECT, 54,122 cells for Mesmer and 144,849 cells for StarDist; cell count was calculated across n = 120 fields of view with detectable gene expression. For b, n = 120 fields of view with detectable gene expression. In a-b, each box plot ranges from the first to third quartile with the median as the horizontal line. The lower whisker extends to 1.5 times the interquartile range below the first quartile, while the upper whisker extends to 1.5 times the interquartile range above the third quartile.Source dataExtended Data Fig. 4 Subsets of B cells and plasma cells.a. UMAP feature plots showing the expression levels of marker genes for B cells and plasma cells. b-c. Dot plots of pathway enrichment analyses for subclusters of C1-CD24+ B cells (b) and C2-JCHAIN+ plasma cells (c). Dot size indicates the number of hits. Dot color indicates Z-score. Pathway enrichment was assessed using a one-sided Fisher’s exact test, with \(P\) values adjusted for multiple comparisons.Source dataExtended Data Fig. 5 Subsets of cancer-associated epithelial cells.a. UMAP feature plots showing the expression levels of marker genes in epithelial and malignant cells. b-c. Dot plots of pathway enrichment analyses for C1-TFF1+ PMC (b) and C3-TFF2+ GMC (c). Dot size indicates the number of hits. Dot color indicates the Z-score. Pathway enrichment was assessed using a one-sided Fisher’s exact test, with \(P\) values adjusted for multiple comparisons. d. Heatmap showing mean Z-scores of marker gene expression across subclusters of epithelial and malignant cells.Source dataExtended Data Fig. 6 Evaluation of segmentation methods on downstream spatial single-cell analysis of the GAC dataset.a. Box plots of the adjusted Rand index (ARI) and purity of the Leiden clustering of the reconstructed spatial single-cell transcriptome segmented by DISSECT, Cellpose27,28, Mesmer29, StarDist33,34,35, BIDCell32 and SCS30 on the GAC Stereo-seq dataset. b. Box plots of the ratio of IGHA1 (left) and IGKC (right) expression in B cells automatically annotated by CellTypist55 to total expression within B cells segmented by DISSECT, Cellpose27,28, Mesmer29, StarDist33,34,35, BIDCell32 and SCS30 on the GAC Stereo-seq dataset. c. (left) Spatial maps of cell type annotation by CellTypist55 on the GAC dataset based on single-cell segmentations by DISSECT, Cellpose27,28, Mesmer29, StarDist33,34,35, BIDCell32 and SCS30. (right) Spatial expression maps of malignant cell marker genes (TFF1 and MUC1). In a-b, each box plot ranges from the first to third quartile with the median as the horizontal line. The lower whisker extends to 1.5 times the interquartile range below the first quartile, while the upper whisker extends to 1.5 times the interquartile range above the third quartile. For a and b, n = 6 image patches with matched spatial transcriptomic data.Source dataExtended Data Fig. 7 Subsets of fibroblasts.a. UMAP feature plots showing the expression levels of marker genes in fibroblast subclusters. b. Dot plot of pathway enrichment analysis for C3-COL1A1+ myCAF. Dot size indicates the number of hits. Dot color indicates the Z-score. Pathway enrichment was assessed using a one-sided Fisher’s exact test, with \(P\) values adjusted for multiple comparisons. c. Heatmap showing mean Z-scores of marker gene expression across fibroblast subsets. d. Pseudotime plot showing inferred differentiation trajectories among fibroblast subsets, with cells colored by their subcluster identity. e. RNA velocity projections overlaid on the UMAP illustrating predicted dynamic transcriptional states within fibroblast subsets, where streamlines indicate the predicted direction of differentiation.Source dataExtended Data Fig. 8 Subsets of macrophages.a. UMAP feature plots showing the expression levels of marker genes across macrophage subclusters. b. Pseudotime plot showing inferred differentiation trajectories within macrophage subsets, with cells colored by their subcluster identity. c. RNA velocity projections overlaid on the UMAP illustrating predicted dynamic transcriptional states within macrophage subsets, where streamlines indicate the predicted direction of differentiation. d. Heatmap showing mean Z-scores of marker gene expression across macrophage subsets.Source dataExtended Data Fig. 9 Differential gene expression analysis between non-responder and responder groups across overlapping niches.a-b. Multi-group differential volcano plots showing up- and down-regulated genes in Niche 20 before anti-PD-1 treatment (a) and after anti-PD-1 treatment (b). c. Multi-group differential volcano plots of differentially expressed genes across malignant cell-dominant niches before anti-PD-1 treatment. d. Multi-group differential volcano plots of differentially expressed genes across cancer-associated fibroblast-dominant niches after anti-PD-1 treatment. For a-d, each data point represents a differentially expressed gene (DEG), with non-significant changes (adjusted \(P\) values ≥ 0.01) highlighted in grey and significant changes (adjusted \(P\) values