Focal hotspot and diffuse immune subtypes of tumor-infiltrating lymphocytes: AI-powered spatial clustering classification and its clinical relevance to HER2 expression in triple-negative breast cancer Authors: Ting Xie, Shuying Ai, Chen Liu, Bin Luo, Honglin Yan, Hongfeng Zhang, Shuaijun Chen, Zhongtao Chen, Tian Jin, Jingping Yuan Published: 2025 ABSTRACT PurposeThis study aimed to define spatial immune subtypes of tumor-infiltrating lymphocytes (TILs) using artificial intelligence (AI)-powered analysis and investigate their association with distinct human epidermal growth factor receptor-2 (HER2) expression levels, response to neoadjuvant chemotherapy (NAC), and patient survival outcomes in triple-negative breast cancer (TNBC).MethodsWe conducted a multicenter study involving TNBC patients receiving NAC, stratified into HER2-0, HER2-ultralow, and HER2-low subgroups. An AI-based cell classifier was employed to identify TILs (AI-TILs) and extract spatial coordinates from pathology images. Using unsupervised learning of spatial clustering analysis to identify immune subtypes. The performance of the AI model was benchmarked against four experienced pathologists. Associations among TILs spatial subtypes, HER2 status, NAC response including pathologic complete response (pCR) and residual cancer burden (RCB), and survival outcomes were systematically evaluated.ResultsAI-TILs demonstrated strong agreement with both senior pathologists, and unsupervised clustering revealed two spatial subtypes: the focal hotspot subtype and the diffuse immune subtype, the latter exhibited broader TIL hotspot areas, lower peak densities, higher pCR rates, and significantly prolonged disease-free survival (DFS). RCB-III status was inversely associated with the diffuse immune subtype, suggesting a link between diffuse immune subtype and good NAC response. Postmenopausal status was independently linked to the focal hotspot pattern. Although HER2 expression was associated with TILs spatial subtypes, it was not an independent influencing factor. In the HER2-low subgroup, the diffuse subtype was significantly associated with better pCR and lower RCB scores, whereas no such relationship was observed in HER2-0 or HER2-ultralow groups. Alluvial and standardized residual analysis further validated that focal hotspot/HER2-low tumors were enriched in RCB-III (residual = 3.26), while diffuse/HER2-low tumors were enriched in RCB-0 (residual = 1.30), suggesting divergent trajectories of immune architecture and chemoresponsiveness.ConclusionThis study distinguished focal hotspot and diffuse immune subtypes of TILs with distinct clinical implications in TNBC. The diffuse immune subtype correlated with enhanced NAC response and favorable prognosis, particularly in HER2-low TNBC. These findings highlighted the spatial immune architecture as a promising biomarker to refine treatment stratification and deepen our understanding of immune heterogeneity in HER2-low TNBC.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12967-025-07608-7. Introduction Triple-negative breast cancer (TNBC), characterized by the absence of estrogen receptor (ER), progesterone receptor (PR), and human epidermal growth factor receptor 2 (HER2) expression, is associated with high aggressiveness and an elevated risk of recurrence. Neoadjuvant chemotherapy (NAC) represents a critical treatment strategy for TNBC patients, with those achieving pathological complete response (pCR) demonstrating significantly prolonged survival [1]. Recent advances across oncology research have reinforced the central role of the tumor microenvironment (TME) and immune-molecular biomarkers in shaping disease progression and therapeutic response [2–4]. Recent molecular analyses supporting the synergy of immune checkpoint inhibitors with anti-angiogenic agents illustrate how targeting both immune evasion and vascular remodeling can reshape antitumor immunity [5]. Such multidimensional perspectives parallel growing interest in quantifying immune spatial heterogeneity in solid tumors, including breast cancer. Beyond hematologic disease, meta-analytical evidence from endocrine disorders—such as subclinical hyperthyroidism affecting hormonal regulation and cellular function—highlights how subtle systemic physiological variations can influence cellular microenvironments, further supporting the need for refined, quantitative approaches to characterize immune states [6]. Together, these studies reflect a converging understanding that immune and microenvironmental biomarkers capture biologically meaningful heterogeneity with direct clinical implications. Within this broader context, TNBC represents an archetype of immunologically variable disease, in which tumor-infiltrating lymphocytes (TILs) serve as both prognostic and predictive indicators [7]. Yet, current TIL assessment paradigms predominantly rely on stromal TIL percentages, overlooking the critical spatial dimension where immune cells cluster. Recent technological advances in artificial intelligence (AI)-powered digital pathology now enable precise characterization of TIL spatial architectures, revealing previously unrecognized immune microenvironment heterogeneity [8, 9]. However, the clinical implications of distinct TIL spatial patterns, particularly in the context of HER2 expression TNBC—a newly defined entity with unique biological behaviors—remain unexplored. According to immunohistochemistry (IHC) and fluorescence in situ hybridization (FISH), HER2-negative includes HER2 IHC 0, IHC 1+, or IHC 2+/FISH non-amplified. Emerging studies further stratified HER2-negative status of breast cancer into three subgroups: HER2-0 (IHC score 0, no detectable membrane staining), HER2-ultralow (IHC score 0 with ≤ 10% of tumor cells showing faint/incomplete membrane staining), and HER2-low (IHC 1 + or 2 + with negative FISH). Growing evidence suggestd that HER2-low breast cancer exhibited distinct clinicopathological features, treatment responses, and prognostic outcomes compared to HER2-0 disease [10]. The DESTINY-Breast 04 trial revealed that the novel antibody-drug conjugate (ADC) trastuzumab deruxtecan (T-DXd) confers substantial clinical benefits even in HER2 low expression breast cancer [11, 12]. Subsequent findings from DESTINY-Breast 06 further demonstrated that T-DXd significantly improves progression-free survival in patients with HER2-ultralow expression [13]. HER2-low tumors often display more aggressive clinicopathological features. Among studies investigating NAC efficacy and survival outcomes across HER2 expression subtypes, a landmark retrospective analysis by Denkert et al. (N = 2,310) reported that HER2-low tumors exhibited lower pCR rates but better overall and recurrence-free survival compared to HER2-0 cases [14]. In contrast, numerous other studies failed to identify significant survival or pCR differences between these subgroups [15–18]. However, research on HER2 expression subgroups of TNBC remained notably lacking [19], therefore, the TNBC in this study were divided into three subgroups based on HER2 expression for further study. Through unsupervised learning of TIL spatial coordinates, we identified two fundamentally distinct immune subtypes: the focal hotspot subtype, characterized by dense but geographically restricted lymphocyte aggregates, and the diffuse immune subtype, exhibiting widespread but lower-density TIL infiltration. Importantly, these subtypes demonstrated striking associations with HER2 expression gradients, while HER2-0 tumors predominantly showed diffuse patterns, HER2-low TNBC exhibited increasing prevalence of focal hotspots, suggesting HER2-mediated modulation of immune spatial organization. This study employed AI-powered spatial analysis to delineate two distinct TILs immune subtypes. We systematically investigated their associations with HER2 expression levels, NAC response (pCR and residual cancer burden (RCB) classification), and patient survival outcomes, aiming to establish a novel spatial framework for understanding tumor-immune interactions in TNBC. Importantly, spatial distribution patterns outperformed conventional TIL density metrics in predicting NAC efficacy. Our findings opened new avenues for spatially informed treatment strategies based on HER2 expression levels in TNBC. Materials and methods Patient cohort We conducted a retrospective multicenter study enrolling female patients (age ≥ 18 years) with invasive breast carcinoma of no special type who underwent core needle biopsy-confirmed TNBC (defined by IHC negativity for ER, PR, and HER-2) and received 4–8 cycles of NAC followed by definitive surgery between October 2019 and June 2024 across three medical centers: Renmin Hospital of Wuhan University (RHWU, discovery cohort, n = 96), Wuhan Central Hospital (WCH, validation cohort, n = 18), and Hanchuan People’s Hospital (HPH, validation cohort, n = 17). Clinicopathological parameters were systematically documented, including: demographic characteristics (age, menopausal status), tumor features (size, Lymph node metastasis, Ki-67 index, histological grade), treatment response metrics (residual cancer burden classification post-NAC and pCR). Follow-up outcomes encompassed DFS, with the observation period commencing from initial diagnosis until recurrence, metastasis, or death. All pathological specimens and clinical data underwent centralized review by specialized breast pathologists. Scanning and pre-processing of WSIs To ensure suitability for machine learning-based analysis, all hematoxylin and eosin (H&E)-stained slides were reviewed by breast pathologists. Blurry slides, those with uneven staining, fading, air bubbles, or folds were excluded. We scanned H&E-stained slides from all three cohorts using a KF-PRO-005 scanner (KFBIO, Zhejiang, China) at 20× magnification, generating whole-slide images (WSIs). To standardize H&E staining across cohorts, we employed the “estimate stain vectors” function in QuPath [20] (version 0.5.0; https://qupath.github.io/, accessed on 2 December 2023), which supports color deconvolution to separate hematoxylin (nuclear staining) and eosin (cytoplasmic staining) channels. Definition and quantification of TILs by cell classifier based on machine learning TILs were defined as lymphocytes infiltrating tumor-associated regions. Pathologists first delineated regions of interest (ROIs) encircled by tumor tissue using the circular annotation tool in QuPath. The Segment Anything Model (SAM, https://github.com/facebookresearch/segment-anything) [21], a deep learning-based approach, was then employed for semi-automated cell segmentation, identifying three distinct cell populations: tumor cells, TILs, and stromal cells (including fibroblasts and endothelial cells in peritumoral stroma). AI-TILs were quantified as the percentage of TILs among all cells within each ROI. All annotations underwent rigorous review by two independent pathologists, with discordances resolved through consensus discussion. The “Cell Detection” function in QuPath was employed to extract cellular features. A Random Forest Classifier was trained using the following parameters: number of trees = 100, max depth = 10, and minimum samples per leaf = 5. Training iterations were performed on annotated regions, with pathologist review and retraining until classification accuracy exceeded 90%. The trained cell classifiers were applied to all WSIs and the data of all cell coordinates were exported. Figure 1 outlines the detailed workflow. Fig. 1Study workflow Study workflow A total of 562 patients were screened, and 96 eligible TNBC cases were included for model training. Two external cohorts (128 and 84 screened) provided 18 and 17 eligible TNBC cases for validation. Pathologist-annotated TILs were used to train the AI classifier, which was then applied to all cohorts for AI-TILs quantification and subsequent spatial and outcome analyses. Human-evaluated tumor-infiltrating lymphocytes Four pathologists with varying levels of expertise independently evaluated TILs in all slides from the discovery and validation cohorts. These included: Doctor A, an intern pathologist with 1–3 years of clinical experience; Doctor B, an intermediate-level pathologist with 3–10 years of practice; Doctor C and Doctor D, two senior pathologists with over 10 years of experience, of whom Doctor C was more experienced in evaluating TILs, with his interpretation as the gold standard. All evaluators were experienced in clinical TILs scoring. Following international TILs working group guidelines [22], TILs were assessed within tumor-infiltrated regions, with manual interpretation of TILs defined as the percentage of ROI area occupied by lymphocytes (including plasma cells but excluding polymorphonuclear leukocytes). Evaluations were performed at 200–400× magnification on one representative section per patient, with quantification in 10% increments. Spatial feature extraction and unsupervised clustering of TILs Spatial pattern analysis of TILs was performed using their computationally identified coordinates. A kernel density estimation approach was applied to generate heatmaps, with the top 20% density regions defined as hotspots. For each hotspot, we quantified its area (µm²/mm²) and centroid coordinates (arithmetic mean). TILs’ spatial clustering tendency was evaluated via nearest-neighbor distance analysis, with statistical significance assessed through Monte Carlo simulations (implemented using the R package spatstat). In the discovery cohort, unsupervised clustering (k-means, k = 2) was performed based on three key spatial distribution features (hotspot area, peak density value, mean nearest-neighbor distance (Mean NND)). Prior to clustering, all features were Z-score normalized. The algorithm was run with 25 iterations to optimize centroid positions, using a fixed random seed to ensure reproducibility. This analysis consistently identified two distinct TILs spatial phenotypes across all runs. Interpretation of HER2 IHC and stratification criteria HER2 IHC (clone 4B5, Ventana) was evaluated by two specialized breast pathologists. In cases of discordance, a senior breast pathologist provided adjudication. HER2 scoring followed the ASCO/CAP guidelines [23]. Based on HER2 expression status, cases were classified into three subgroups: HER2-0: IHC score 0 (no detectable membrane staining); HER2-ultralow: IHC score 0 with ≤ 10% of tumor cells showing faint/incomplete membrane staining; HER2-low: IHC 1 + or 2 + with negative FISH. Assessment of residual cancer burden The RCB scoring and classification were evaluated by board-certified breast pathologists with specialized training following established guidelines [24]. The RCB score incorporates the following parameters: the extent of residual invasive carcinoma in the primary breast tumor, cellularity of the residual tumor, proportion of carcinoma in situ, number of positive lymph nodes, and the largest metastatic deposit diameter in lymph nodes. Based on the composite score, RCB is stratified into four categories: RCB-0 (pathological complete response), RCB-I (minimal residual disease), RCB-II (moderate residual disease), and RCB-III (extensive residual disease), reflecting progressively worse therapeutic responses. Statistical analysis All statistical analyses were performed using R version 4.3.0. In the RHWU cohort, we determined the optimal cut-off value of AI-TILs (28%) by receiver operating characteristic (ROC) curve analysis based on pCR status following NAC. Patients were subsequently stratified into AI-TILs-low and AI-TILs-high groups using this threshold. Categorical variables were compared using Pearson’s χ² test. Univariate and multivariate logistic regression analyses were employed to evaluate the association between pCR achievement and various clinicopathological parameters, including AI-TILs status. The prognostic significance of different HER2 expression patterns in TNBC was assessed using Kaplan-Meier survival curves with log-rank tests. A two-sided P < 0.05 was considered statistically significant for all analyses. Results Patient characteristics Detailed patient characteristics are presented in Table 1. A single H&E-stained WSI was selected for analysis per patient. The RHWU cohort was designated as the discovery set, while WCH and HPH served as external validation sets. Table 1Baseline characteristics of the study populationClinical featuresRHWU cohort(n = 96)WCH cohort(n = 18)HPH cohort(n = 17)Age< 5047 (49.0%)3 (16.7%)4 (23.5%)≥ 5049 (51.0%)15 (83.3%)13 (76.5%)Histologic grade11 (0%)0 (0%)0 (0%)214 (14.6%)6 (33.3%)4 (23.5%)381 (84.4%)12 (66.7%)13 (76.5%)Ki-67< 207 (7.3%)1 (5.6%)4 (23.5%)≥ 2089 (92.7%)17 (94.4%)13 (76.5%)Lymph node metastasisYes49 (51.0%)8 (44.4%)2 (11.8%)No47 (49.0%)10 (55.6%)15 (88.2%)BreastLeft55 (57.3%)9 (50.0%)10 (58.8%)Right41 (42.7%)9 (50.0%)7 (41.2%)Tumor size (cm)≤ 265 (67.7%)8 (44.4%)11 (64.7%)> 231 (32.3%)10 (55.6%)6 (35.3%)PostmenopausalYes41 (42.7%)13 (72.2%)14 (82.4%)No55 (57.3%)5 (27.8%)3 (17.6%)HER2 expressionHER2-016 (16.7%)4 (22.2%)7 (41.2%)HER2-ultralow30 (31.3%)3 (16.7%)2 (11.8%)HER2-low50 (52.0%)11 (61.1%)8 (47.0%)TILs expressionLow59 (61.5%)16 (88.9%)13 (76.5%)High37 (38.5%)2 (11.1%)4 (23.5%)pCRYes3316No631711 Table 1Baseline characteristics of the study populationClinical featuresRHWU cohort(n = 96)WCH cohort(n = 18)HPH cohort(n = 17)Age< 5047 (49.0%)3 (16.7%)4 (23.5%)≥ 5049 (51.0%)15 (83.3%)13 (76.5%)Histologic grade11 (0%)0 (0%)0 (0%)214 (14.6%)6 (33.3%)4 (23.5%)381 (84.4%)12 (66.7%)13 (76.5%)Ki-67< 207 (7.3%)1 (5.6%)4 (23.5%)≥ 2089 (92.7%)17 (94.4%)13 (76.5%)Lymph node metastasisYes49 (51.0%)8 (44.4%)2 (11.8%)No47 (49.0%)10 (55.6%)15 (88.2%)BreastLeft55 (57.3%)9 (50.0%)10 (58.8%)Right41 (42.7%)9 (50.0%)7 (41.2%)Tumor size (cm)≤ 265 (67.7%)8 (44.4%)11 (64.7%)> 231 (32.3%)10 (55.6%)6 (35.3%)PostmenopausalYes41 (42.7%)13 (72.2%)14 (82.4%)No55 (57.3%)5 (27.8%)3 (17.6%)HER2 expressionHER2-016 (16.7%)4 (22.2%)7 (41.2%)HER2-ultralow30 (31.3%)3 (16.7%)2 (11.8%)HER2-low50 (52.0%)11 (61.1%)8 (47.0%)TILs expressionLow59 (61.5%)16 (88.9%)13 (76.5%)High37 (38.5%)2 (11.1%)4 (23.5%)pCRYes3316No631711 Baseline characteristics of the study population Evaluation of consistency between the cell classifier and pathologists in TILs assessment As detailed in Fig. 2, following iterative pathological review and adjudication of discordant cases, the cell classifier underwent progressive optimization to enhance classification accuracy. Fig. 2Iterative refinement of the cell classifier during the training phase. a-c: the original images, d-f: their corresponding outputs generated by the cell classifier during successive rounds of training using RHWU samples. TILs are marked in purple, tumor cells in red, and stromal cells in green. Panels d-f illustrate the improvement in visual concordance with pathologist annotations as the classifier was iteratively refined Iterative refinement of the cell classifier during the training phase. a-c: the original images, d-f: their corresponding outputs generated by the cell classifier during successive rounds of training using RHWU samples. TILs are marked in purple, tumor cells in red, and stromal cells in green. Panels d-f illustrate the improvement in visual concordance with pathologist annotations as the classifier was iteratively refined To evaluate the reliability of AI-TILs, we compared its performance with four pathologists (Doctor A, B, C and D) in discovery and validation cohorts. In the discovery cohort, senior pathologists (Doctor C and D) exhibited excellent interobserver agreement (κ = 0.90), supporting Doctor C’s results as the gold standard. AI-TILs demonstrated strong concordance with Doctor C (κ = 0.87) and Doctor D (κ = 0.82). When compared against the gold standard, AI-TILs showed higher consistency in identifying low TILs cases (Fig. 3a, b). Similar trends were observed in the validation cohort, where Doctor C and D maintained high agreement (κ = 0.80), reinforcing the robustness of the gold standard. AI-TILs achieved moderate agreement with Doctor C (κ = 0.68) and Doctor D (κ = 0.72). Notably, the agreement heatmaps showed that AI-TILs achieved higher concordance with the gold-standard annotations in low-TILs cases than in sections with higher TILs levels (Fig. 3c, d). These findings indicate that AI-TILs is a reliable tool for TILs assessment and performs particularly well in identifying low TILs infiltration, with consistency comparable to that of experienced pathologists. Fig. 3Interobserver agreement analysis of TILs assessment between AI-TILs and pathologists. a, Cohen’s kappa heatmap comparing AI-TILs with four pathologists (Doctors A-D) in the discovery cohort. b, Agreement heatmap showing concordance between AI-TILs and the gold-standard annotations (Doctor C) in the discovery cohort. c, Cohen’s kappa heatmap for the validation cohort. d, Agreement heatmap illustrating concordance between AI-TILs and the gold-standard annotations in the validation cohort Interobserver agreement analysis of TILs assessment between AI-TILs and pathologists. a, Cohen’s kappa heatmap comparing AI-TILs with four pathologists (Doctors A-D) in the discovery cohort. b, Agreement heatmap showing concordance between AI-TILs and the gold-standard annotations (Doctor C) in the discovery cohort. c, Cohen’s kappa heatmap for the validation cohort. d, Agreement heatmap illustrating concordance between AI-TILs and the gold-standard annotations in the validation cohort TILs spatial clustering identified focal-hotspot and diffuse immune subtypes associated with NAC response and prognosis Unsupervised K-means clustering based on these spatial metrics identified two immune phenotypes: Cluster 1 (Focal-hotspot subtype) featured small, densely packed immune hotspots with sparse background infiltration, while Cluster 2 (Diffuse-immune subtype) was characterized by broadly distributed TILs with minimal clustering (Fig. 4a). Compared to Cluster 1, Cluster 2 showed larger hotspot areas and lower peak densities (all P < 0.05, (Fig. 4b-c)). Clinically, the Diffuse-immune subtype was associated with higher pCR rates (Fig. 4e) and significantly longer DFS (Fig. 4f). Figure 5 illustrated the representative images of the Focal-Hotspot subtype (Fig. 5a-b) and Diffuse-Immune subtype (Fig. 5c-d), both shown at 200× magnification. Univariate analysis linked TILs spatial subtypes with pCR, but multivariable logistic regression did not support them as independent predictors (Supplementary Table 1), suggesting that predictive value of TILs spatial subtypes may be confounded or mediated by other clinicopathological factors. Fig. 4TILs clustering identified two distinct immune subtypes. a, Spatial analysis identified two immune subtypes: Focal-hotspot subtype (Cluster 1), characterized by small but dense immune hotspots with overall sparse infiltration; and Diffuse-immune subtype (Cluster 2), marked by widespread and less concentrated TILs distribution. b-d: Comparison between Cluster 1 and Cluster 2 in terms of (b) hotspot area, (c) peak TIL density, and (d) mean nearest-neighbor distance. e, Comparison of pCR rates between the two clusters. f, Kaplan-Meier curves of DFS stratified by 2 immune subtypes TILs clustering identified two distinct immune subtypes. a, Spatial analysis identified two immune subtypes: Focal-hotspot subtype (Cluster 1), characterized by small but dense immune hotspots with overall sparse infiltration; and Diffuse-immune subtype (Cluster 2), marked by widespread and less concentrated TILs distribution. b-d: Comparison between Cluster 1 and Cluster 2 in terms of (b) hotspot area, (c) peak TIL density, and (d) mean nearest-neighbor distance. e, Comparison of pCR rates between the two clusters. f, Kaplan-Meier curves of DFS stratified by 2 immune subtypes Fig. 5Representative histologic appearances of the two spatial immune subtypes. a-b (×200): Focal-hotspot subtype (Cluster 1), showing small and sharply demarcated high-density TIL aggregates on HE (a) and the corresponding TIL hotspot map (b). c-d (×100): Diffuse immune subtype (Cluster 2), characterized by widespread, low-density TIL infiltration on HE (c) and its corresponding TIL distribution map (d) Representative histologic appearances of the two spatial immune subtypes. a-b (×200): Focal-hotspot subtype (Cluster 1), showing small and sharply demarcated high-density TIL aggregates on HE (a) and the corresponding TIL hotspot map (b). c-d (×100): Diffuse immune subtype (Cluster 2), characterized by widespread, low-density TIL infiltration on HE (c) and its corresponding TIL distribution map (d) Clinicopathological factors associated with two TILs spatial immune subtypes To further explore the determinants of TIL spatial distribution patterns, we performed a multivariable logistic regression analysis using immune subtype classification (Focal-hotspot vs. Diffuse immune) as the dependent variable. The analysis revealed that several clinicopathological factors were independently associated with immune subtype (Table 2). These variables represent the complete set included in the model, and no additional covariates outside those listed in Table 2 were incorporated. Specifically, RCB-III status was significantly associated with a decreased likelihood of exhibiting the Diffuse-Immune Subtype (OR = 0.17, 95% CI: 0.04 ~ 0.69, P = 0.013), indicating a strong association between poor NAC response and the Focal-Hotspot pattern. In addition, high Ki-67 expression was independently associated with the Diffuse-Immune Subtype (OR = 10.16, 95% CI: 1.05 ~ 98.66, P = 0.046), suggesting that tumors with higher proliferative activity tend to harbor more diffusely infiltrated TILs. Menopausal status also remained an independent predictor after full adjustment. Postmenopausal patients demonstrated a significantly lower likelihood of exhibiting the Diffuse-Immune subtype (OR = 0.20, 95% CI: 0.05–0.83, P = 0.026). Given the relatively modest difference between univariate and multivariate estimates, this finding should be interpreted as an independent clinical correlate, rather than a determinant of spatial immune architecture. The association may reflect hormone-related or age-linked alterations in stromal composition, immune cell recruitment, or tissue remodeling; however, these potential mechanisms remain speculative. Importantly, the observed relationship is hypothesis-generating, and the study design does not permit causal inference. However, in the ordinal logistic regression assessing predictors of HER2 expression levels (categorized as HER2-0 [reference], HER2-ultralow, and HER2-low) (Table 3), cluster membership emerged as a significant predictor in univariate analysis (OR = 0.37, 95% CI: 0.16 ~ 0.86, P = 0.022), but this relationship was attenuated in the multivariate model after adjustment for covariates. These findings suggest that menopausal status may play an independent role in shaping the spatial immune microenvironment, while the association between HER2-low expression and TILs spatial patterns appears to be confounded by other clinicopathological factors and warrants further investigation. Table 2Logistic univariate and multivariate regression analysis of factors influencing the two TILs Spatial immune subtypesVariablesUnivariate analysisMultivariate analysisOR (95%CI) P OR (95%CI) P HER2 expression HER2-01HER2-ultralow0.63 (0.14 ~ 2.83)0.551HER2-low0.27 (0.07 ~ 1.07)0.062 RCB grade 011I0.44 (0.09 ~ 2.30)0.3340.55 (0.08 ~ 3.63)0.531II0.42 (0.13 ~ 1.34)0.1430.48 (0.13 ~ 1.71)0.255III0.13 (0.04 ~ 0.44) 0.001 0.17 (0.04 ~ 0.69) 0.013 Age < 5011≥ 500.35 (0.14 ~ 0.83) 0.018 1.59 (0.37 ~ 6.82)0.533 Ki67 < 2011≥ 2013.07 (1.50 ~ 113.77) 0.020 10.16 (1.05 ~ 98.66) 0.046 Lymph node metastasis No1Yes0.89 (0.38 ~ 2.05)0.783 Breast Left1Right1.10 (0.47 ~ 2.57)0.822 Tumor size (cm) ≤ 21> 20.44 (0.18 ~ 1.07)0.069 Postmenopausal No11Yes0.24 (0.10 ~ 0.58) 0.002 0.20 (0.05 ~ 0.83) 0.026 Values in bold indicate a difference in the P values Table 2Logistic univariate and multivariate regression analysis of factors influencing the two TILs Spatial immune subtypesVariablesUnivariate analysisMultivariate analysisOR (95%CI) P OR (95%CI) P HER2 expression HER2-01HER2-ultralow0.63 (0.14 ~ 2.83)0.551HER2-low0.27 (0.07 ~ 1.07)0.062 RCB grade 011I0.44 (0.09 ~ 2.30)0.3340.55 (0.08 ~ 3.63)0.531II0.42 (0.13 ~ 1.34)0.1430.48 (0.13 ~ 1.71)0.255III0.13 (0.04 ~ 0.44) 0.001 0.17 (0.04 ~ 0.69) 0.013 Age < 5011≥ 500.35 (0.14 ~ 0.83) 0.018 1.59 (0.37 ~ 6.82)0.533 Ki67 < 2011≥ 2013.07 (1.50 ~ 113.77) 0.020 10.16 (1.05 ~ 98.66) 0.046 Lymph node metastasis No1Yes0.89 (0.38 ~ 2.05)0.783 Breast Left1Right1.10 (0.47 ~ 2.57)0.822 Tumor size (cm) ≤ 21> 20.44 (0.18 ~ 1.07)0.069 Postmenopausal No11Yes0.24 (0.10 ~ 0.58) 0.002 0.20 (0.05 ~ 0.83) 0.026 Values in bold indicate a difference in the P values Logistic univariate and multivariate regression analysis of factors influencing the two TILs Spatial immune subtypes Values in bold indicate a difference in the P values Table 3Ordinal logistic regression analysis of factors influencing HER2 expression subgroupsVariablesUnivariate analysisMultivariate analysisOR (95%CI) P OR (95%CI) P Age < 5011≥ 502.21 (1.01 ~ 4.82) 0.047 1.17 (0.42 ~ 3.27)0.766 Ki67 < 201≥ 200.19 (0.02 ~ 1.66)0.133 Lymph node metastasis No1Yes1.97 (0.91 ~ 4.27)0.086 Breast Left1Right0.63 (0.29 ~ 1.36)0.237 Tumor size (cm) ≤ 21> 22.33 (0.99 ~ 5.48)0.052 Postmenopausal No11Yes2.87 (1.28 ~ 6.46) 0.011 2.14 (0.73 ~ 6.26)0.164 RCB grade 01I1.24 (0.32 ~ 4.78)0.755II1.47 (0.58 ~ 3.73)0.413III2.33 (0.80 ~ 6.80)0.121 TILs Cluster Focal-hotspot subtype1Diffuse-immune subtype0.37 (0.16 ~ 0.86) 0.022 0.47 (0.19 ~ 1.14)0.094Values in bold indicate a difference in the P values Table 3Ordinal logistic regression analysis of factors influencing HER2 expression subgroupsVariablesUnivariate analysisMultivariate analysisOR (95%CI) P OR (95%CI) P Age < 5011≥ 502.21 (1.01 ~ 4.82) 0.047 1.17 (0.42 ~ 3.27)0.766 Ki67 < 201≥ 200.19 (0.02 ~ 1.66)0.133 Lymph node metastasis No1Yes1.97 (0.91 ~ 4.27)0.086 Breast Left1Right0.63 (0.29 ~ 1.36)0.237 Tumor size (cm) ≤ 21> 22.33 (0.99 ~ 5.48)0.052 Postmenopausal No11Yes2.87 (1.28 ~ 6.46) 0.011 2.14 (0.73 ~ 6.26)0.164 RCB grade 01I1.24 (0.32 ~ 4.78)0.755II1.47 (0.58 ~ 3.73)0.413III2.33 (0.80 ~ 6.80)0.121 TILs Cluster Focal-hotspot subtype1Diffuse-immune subtype0.37 (0.16 ~ 0.86) 0.022 0.47 (0.19 ~ 1.14)0.094Values in bold indicate a difference in the P values Ordinal logistic regression analysis of factors influencing HER2 expression subgroups Values in bold indicate a difference in the P values The relationship between HER2 expression subgroups and TILs spatial immune subtypes in TNBC To further illustrate the histopathological and immunohistochemical characteristics of HER2 expression in TNBC, representative H&E and corresponding HER2 IHC images were presented in Fig. 6. As shown, TNBC with HER2-0 expression exhibited no membranous HER2 staining (Fig. 6a-b), while HER2-ultralow cases displayed faint, incomplete membranous staining in less than 10% of tumor cells (Fig. 6c-d). In contrast, HER2-low tumors demonstrated weak to moderate complete or incomplete membranous staining in ≥ 10% of tumor cells, corresponding to IHC scores of 1 + or 2 + with negative FISH results (Fig. 6e-f). These morphological and immunophenotypic differences may reflect underlying biological heterogeneity within TNBC subtypes. Fig. 6Representative H&E and corresponding HER2 IHC images of TNBC cases with different levels of HER2 expression, ×200. a-b, H&E staining (a) and HER2 IHC (b) of the HER2-0 subgroup. c-d, H&E staining (c) and HER2 IHC (d) of the HER2-ultralow subgroup. e-f, H&E staining (e) and HER2 IHC (f) of the HER2-low subgroup Representative H&E and corresponding HER2 IHC images of TNBC cases with different levels of HER2 expression, ×200. a-b, H&E staining (a) and HER2 IHC (b) of the HER2-0 subgroup. c-d, H&E staining (c) and HER2 IHC (d) of the HER2-ultralow subgroup. e-f, H&E staining (e) and HER2 IHC (f) of the HER2-low subgroup To evaluate the relationship between HER2 expression status and immune spatial phenotypes, we analyzed the distribution of Focal-hotspot subtype and Diffuse-immune subtype across three HER2 categories: HER2-0, HER2-ultralow, and HER2-low in TNBC. Although no significant differences in the distribution of immune subtypes were observed among the HER2 expression subgroups (Fig. 7a), UMAP-based dimensionality reduction revealed distinct spatial patterns. A significant increasing trend in the proportion of Cluster 1 was observed with rising HER2 expression levels (from HER2-0 to HER2-low), while the proportion of Cluster 2 showed a corresponding decreasing trend (Cochran-Armitage trend test, P < 0.05 for both; Fig. 7b-c). These findings suggested that higher HER2 expression, even within the HER2-0 to HER2-low range, may be associated with a more spatially restricted, hotspot-dominated immune infiltration pattern, whereas lower HER2 expression was linked to a more diffuse immune phenotype. Across all HER2 expression subgroups, the Diffuse-immune subtype exhibited larger TIL hotspot areas (Fig. 7d) and lower peak TIL densities (Fig. 7e) compared to the Focal-hotspot subtype, highlighting distinct spatial infiltration characteristics between the two immune phenotypes. However, these spatial features appeared to be independent of HER2 expression status. Fig. 7Distribution and spatial features of Focal-hotspot and Diffuse-immune subtypes in HER2-low subgroups. a, Stacked bar plot showing the distribution of immune subtypes across HER2-low expression subgroups. b-c, HER2-low expression trends in Cluster 1 (b) and Cluster 2 (c). d-f, Comparison of spatial characteristics between immune subtypes within HER2-low subgroups: (d) hotspot area, (e) peak density, and (f) mean nearest-neighbor distance Distribution and spatial features of Focal-hotspot and Diffuse-immune subtypes in HER2-low subgroups. a, Stacked bar plot showing the distribution of immune subtypes across HER2-low expression subgroups. b-c, HER2-low expression trends in Cluster 1 (b) and Cluster 2 (c). d-f, Comparison of spatial characteristics between immune subtypes within HER2-low subgroups: (d) hotspot area, (e) peak density, and (f) mean nearest-neighbor distance Differential RCB classification across TILs spatial clusters in HER2 expression subgroups To further investigate the association between TILs spatial subtypes and treatment response across HER2 expression subgroups, we analyzed RCB classifications in relation to two identified TILs clusters—Focal-hotspot and Diffuse-immune—within HER2-0, HER2-ultralow, and HER2-low groups. A significant difference in TILs cluster distribution across RCB grades was observed (P = 0.00746; Fig. 8a). The Diffuse-immune cluster was predominantly enriched in RCB 0 (pathologic complete response), while the Focal-hotspot cluster was most prevalent in RCB III, indicating an association with poor therapeutic response. Subgroup analysis further revealed that within the HER2-low group, RCB grades significantly differed between the two clusters (P = 0.017; Fig. 8b), suggesting that spatial immune phenotypes may predict differential responses to NAC in this subgroup. In contrast, no significant differences were found in the HER2-0 and HER2-ultralow groups, implying that the prognostic value of TILs spatial heterogeneity may be particularly relevant in HER2-low TNBC tumors. The alluvial plot (Fig. 8c) further illustrated dominant transition patterns: the Focal-hotspot subtype flowed most frequently toward HER2-low and RCB III, while the Diffuse-immune subtype transitioned primarily to HER2-low and RCB 0. This trend was confirmed by standardized residual analysis (Fig. 8d), where the Focal-hotspot/HER2-low combination was significantly overrepresented in RCB III (residual = 3.26) and underrepresented in RCB 0 (residual = − 2.47), indicating a strong association with chemoresistance. Conversely, the Diffuse-immune/HER2-low group showed modest enrichment in RCB 0 (residual = 1.30), suggesting a potential link to favorable response. Fig. 8Associations among TILs clusters, HER2 expression subgroups, and RCB classification. a, Distribution of TILs clusters across different RCB grades. b, RCB grades distribution between Cluster 1 and Cluster 2 in HER2 expression subgroups. c, Alluvial plot illustrating the transition from TILs clusters to HER2 expression subgroups and subsequent RCB grades. d, Heatmap of standardized residuals depicting the association between two TILs clusters-HER2 expression combined subgroups and RCB grades Associations among TILs clusters, HER2 expression subgroups, and RCB classification. a, Distribution of TILs clusters across different RCB grades. b, RCB grades distribution between Cluster 1 and Cluster 2 in HER2 expression subgroups. c, Alluvial plot illustrating the transition from TILs clusters to HER2 expression subgroups and subsequent RCB grades. d, Heatmap of standardized residuals depicting the association between two TILs clusters-HER2 expression combined subgroups and RCB grades Prognostic and predictive value of TILs spatial subtypes across HER2 expression subgroups To assess the prognostic and predictive value of TIL spatial subtypes in the context of HER2 expression in the TNBC, we conducted survival and NAC response analyses stratified by immune subtype and HER2 status. Kaplan-Meier analysis revealed that within the HER2-0 subgroup, patients with the Focal-hotspot immune subtype had significantly shorter DFS compared to those with the Diffuse-immune subtype (P < 0.05, Fig. 9a). However, in the HER2-ultralow and HER2-low subgroups, no significant differences in DFS were observed between the two spatial immune phenotypes. Conversely, when DFS was compared across HER2 expression subgroups within each immune subtype, no significant survival differences were found, indicating that HER2 expression level did not independently influence DFS within a given immune subtype (Fig. 9b). Additionally, pCR rate analysis revealed that within the HER2-low subgroup, the Focal-hotspot immune subtype exhibited a significantly lower pCR rate compared to the Diffuse-immune subtype (P < 0.05, Fig. 9c), suggesting that spatial immune subtypes may hold predictive value for pCR in HER2-low TNBC. Collectively, these findings highlighted that the prognostic relevance of TIL spatial subtypes may be context-dependent, with potential impact observed predominantly in the HER2-0 subgroup. Fig. 9Prognostic and predictive relevance of TILs spatial subtypes across HER2 expression subgroups. a, Kaplan-Meier curves of DFS stratified by immune subtype (Focal-hotspot vs. Diffuse-immune) within each HER2 expression subgroup. b, Kaplan-Meier curves of DFS stratified by HER2 expression subgroup within each immune subtype. c, Bar plots comparing the pCR rates between the two immune subtypes across HER2 expression subgroups Prognostic and predictive relevance of TILs spatial subtypes across HER2 expression subgroups. a, Kaplan-Meier curves of DFS stratified by immune subtype (Focal-hotspot vs. Diffuse-immune) within each HER2 expression subgroup. b, Kaplan-Meier curves of DFS stratified by HER2 expression subgroup within each immune subtype. c, Bar plots comparing the pCR rates between the two immune subtypes across HER2 expression subgroups Discussion We presented a novel AI-driven spatial classification framework for TILs in TNBC, identifying two clinically relevant immune subtypes: focal hotspot and diffuse immune. This framework captured spatial heterogeneity beyond total TILs counts, offering a new lens for interpreting the tumor-immune interface in various HER2 expression subsets of TNBC. Unlike previous studies that relied on density thresholds or pathologist-based scoring [25, 26], our AI-TILs classifier provided objective and high-resolution spatial analysis, achieving pathologist-level agreement. Denkert et al. were the first to report that TILs could serve as an independent predictor of NAC response in breast cancer, with higher TILs levels strongly correlating with increased pCR rates (40–42%) [27]. Although Denkert also analyzed biopsy samples, their TILs assessment relied on visual evaluation by two pathologists using H&E-stained slides. Numerous studies have employed machine learning or deep learning to analyze the distribution of TILs in WSIs of solid tumors [28, 29]. Some machine learning-based methods rely on region segmentation, dividing tissue into tumor regions and TILs-infiltrated regions, followed by TILs scoring [30]. Whereas, we utilized an AI-based approach, involving cell-level annotation and training on H&E-stained WSIs, enabling more detailed quantification. Previous studies, such as those by Bai et al. and Lu et al., have established the clinical relevance of machine-learning–derived TIL measurements in breast cancer. Bai et al. [31] focused on generating quantitative TIL scores through neural-network classifiers, and Lu et al. [32] provided high-resolution TIL maps and numerous spatial image features. In contrast to these feature-based or score-based approaches, our unsupervised clustering analysis of machine learning-classified cellular spatial data identified two distinct TILs spatial phenotypes. The hotspot region of focal hotspot subtype potentially indicated an active immune response, but spatial constraints suggested that the immunosuppressive microenvironment prevented extensive infiltration of TILs. While diffuse immune subtype signaled stronger tumor antigenicity or weaker immunosuppression, TILs were free to migrate and were usually associated with better prognosis and response to immunotherapy. Intriguingly, the focal hotspot subtype’s ultra-dense focal aggregates likely represent physically constrained immune cells rather than functional infiltration. Higher nearest-neighbor distances indicate significant spatial segregation between TILs, possibly caused by tumor-associated fibrosis or abnormal blood vessel formation. This structural feature may hinder the free migration and functioning of immune cells [33, 34]. We found that the diffuse immune subtype had a lower pCR rate and shorter DFS compared to the focal hotspot subtype. Although conceptually aligned with the four proteomic subtypes of TNBC identified by Mariano et al. [35], including the immune-activated phenotype enriched in TILs and linked to favorable prognosis, our approach offered a data-driven, spatially resolved classification framework based on machine learning, with greater objectivity, reproducibility, and clinical scalability. Unlike conventional immunophenotyping (hot or cold tumor) or Daniel Chen’s tripartite classification (immune inflamed/excluded/desert) [36], our spatial clustering provided TNBC-specific stratification, though potentially population-dependent. Since the preliminary results of the DESTINY-Breast 06 trial demonstrated the efficacy of ADC in patients with HER2-ultralow breast cancer, there follows an ongoing wave of multidimensional studies in the low/ultralow HER2 expression group, with a few consistent studies on HER2 interpretation [37–40]. Most previous studies have failed to find differences in pCR rates and survival based on HER2 expression status [41–44]. However, we uniquely evaluated the prognosis and NAC efficacy of HER2-ultralow TNBC when comparing with other HER2 expression. Moreover, our study revealed a significant association between HER2 expression levels and the spatial distribution of TILs. Specifically, as HER2 expression increased (from HER2-0 to HER2-ultralow and further to HER2-low), the proportion of the Focal hotspot immune subtype rised markedly, while the Diffuse immune subtype exhibitd a corresponding decline. This observation suggested that HER2 status may influence the spatial organization of the tumor immune microenvironment, potentially modulating localized immune activation. The enrichment of the Focal hotspot subtype in HER2-low tumors implied that higher HER2 expression fostered the formation of immunologically active niches, where TILs aggregated in discrete regions rather than dispersing diffusely. Conversely, the decline in the Diffuse immune subtype may reflect a more immunosuppressive milieu in HER2-0 tumors, where TILs were scattered without forming functional clusters. These findings carry potential clinical implications. HER2-low TNBC tumors, with their higher prevalence of Focal hotspot subtype, might exhibit enhanced susceptibility to immune-based therapies. Further investigation was warranted to elucidate the mechanistic interplay between HER2 and immune spatial architecture, as well as its therapeutic relevance. Our data underscored a progressive shift in immune spatial subtypes with increasing HER2 expression, highlighting HER2 as a potential regulator of immune localization. This insight may inform future strategies for patient stratification and immunomodulatory interventions in HER2-expressing tumors. The diffuse immune subtype was strongly associated with favorable NAC response and lower RCB scores, particularly in HER2-low tumors. Notably, spatial subtype was not an independent prognostic factor in multivariable analysis, but its interplay with HER2 status uncovered distinct immunological trajectories—highlighting the potential of integrating spatial metrics with molecular phenotyping. The focal-hotspot immune subtype, which was more frequently observed in postmenopausal patients and HER2-low tumors with RCB-III, may reflect a spatially constrained immune response. Importantly, postmenopausal status is not interpreted as a determinant of spatial architecture but rather as an independent clinical correlate, and this association is purely observational and hypothesis-generating. Limited hormonal and stromal changes after menopause may partly contribute to this pattern, although these potential mechanisms remain speculative. These insights underscore the biological and therapeutic relevance of spatial TIL patterns. As HER2 expression increased from HER2-0 to HER2-low, we observed a rise in focal hotspot prevalence. This aligned with evidence that HER2 signaling modulates chemokine (including CX3CL1, CCL2 and CXCR4) secretion to create immune “cold” niches [45–48]. Our alluvial analysis further showed that focal hotspot/HER2-low tumors were more likely to proceed to RCB-III, suggesting that this subtype represented a spatial immune evasion phenotype that was resistant to conventional NAC. Compared to prior work, our study uniquely connects immune spatial architecture with HER2 expression gradients in TNBC, proposing a novel classification system with translational relevance. However, the overall cohort size and especially the HER2-ultralow and HER2-low subgroups in the external validation cohorts are small; and future studies with larger, prospectively collected, multi-center cohorts are needed to validate and refine these observations. Although multicenter samples were used prospective cohorts are needed to validate the reliability of AI-TILs thresholds. Spatial analysis based only on 2D sections may underestimate the 3D heterogeneity of the real tumor microenvironment, and future improvements incorporating techniques such as multiplex immunofluorescence imaging and exploring the stability of spatial subtyping of TILs to predict efficacy are needed. Conclusion This multicenter study demonstrated that AI-based spatial clustering can identify reproducible TILs spatial subtypes in TNBC, namely the focal hotspot and diffuse immune patterns, which showed distinct clinical behaviors. These subtypes were significantly associated with HER2 expression levels and RCB. Specifically, the diffuse immune subtype—more prevalent in HER2-0 TNBC—was linked to lower RCB gardes and better treatment response, while the focal hotspot subtype was enriched in HER2-low tumors with poor pathological response (RCB-III). Our findings revealed a spatial immunologic dimension to HER2 expression of TNBC biology, suggesting that AI-powered spatial profiling may improve risk stratification and therapeutic guidance in this subgroup. Supplementary information Below is the link to the electronic supplementary material. Supplementary Material 1 Supplementary Material 1