Pan-cancer single-cell and spatial transcriptomics analyses delineate response-associated heterogeneity and therapeutic targets of tumor-infiltrating B cells following immune checkpoint blockade Authors: Jialing Fang, Hangyu Liu, Jun Lei, Yongshun Chen, Jingjing Wang Published: 2026 ABSTRACT AbstractTumor-infiltrating B cells (TIBs) are emerging as central regulators of anti-tumor immunity, but their biological functions, spatial niches, and cross talk with tumor-infiltrating lymphocytes vary widely across cancer types, particularly with regard to cancer immunotherapies. Yet a pan-cancer atlas linking their transcriptional profile to the immune checkpoint blockade (ICB) response has been missing. Here, we presented the pan-cancer ICB response B cell atlas, constructed from 688 single-cell transcriptomes (24 cancer types, 241,645 cells). Twenty-four B cell subsets were identified, and their proportion dynamics and transcriptomic features across cancers were revealed. B cell subsets proportion-based NMF analyses identified 5 TIME subtypes in which TIME-Plasma and TIME-Memory showing repressed apoptosis, higher antigen presentation, and enrichment in responders were correlated with better survival in several cancers. Pseudo-time trajectories delineated two conserved differentiation pathways that branch at the memory B cell node and showed distinct correlations with B cell apoptosis and ICB response. Pan-cancer spatial deconvolution showed that several responder-derived B cell subsets including plasma cells, memory B cells, and activated B cells were more co-occurred compared to non-responder-derived B cell subsets. Utilizing pan-cancer TCGA datasets, the clinical heterogeneity of B cell subsets from distinct response groups was revealed. We constructed a pan-cancer ICB response Geneformer model and in silico perturbed all genes. Thirteen candidate genes, which were significantly correlated with the B cell ICB response state transition, were identified. Overall, our study illuminates the heterogeneity of TIBs and improves our understanding of cancer-specific B cell subsets within the context of tumor immunotherapies.Supplementary InformationThe online version contains supplementary material available at 10.1007/s00262-026-04449-1.Keywords: Pan-cancer, Tumor-infiltrating B cells, Immune checkpoint blockade, scRNA-seq, ST-seq Introduction The development of ICB immunotherapy marked a significant breakthrough in the field of cancer treatment, yielding promising clinical outcomes in recent years [1, 2]. While T cells have been the primary focus of ICB research [3], B cells have not received comparable attention despite their abundance and versatility within the tumor microenvironment (TME) [4–6]. There is a growing interest in investigating TIBs [7], but their influence within the TME and their impact on ICB response remain incompletely understood [8]. Currently, B cells are broadly classified into subgroups, including naïve B cells, plasma cells, memory B cells, GC B cells, proliferative B cells, and activated B cells [9–11]. However, this conventional classification often oversimplifies the heterogeneity of tumor-infiltrating B cells [8, 12]. There were differences in the proportion [13, 14] and transcriptomes [9, 11] of B cell subsets in the TME with distinct ICB response degrees, which suggested that B cells may be used for next-generation immunotherapy [15–17]. Broad classification fails to capture the full complexity of B cells. Therefore, instead of identifying B cells as a simple classification, contemporary single-cell research perceives their functional states between responders and non-responders as a pattern of heterogeneities [18–20]. Recent advancements in single-cell RNA sequencing (scRNA-seq) have greatly enhanced our ability to observe and decipher the heterogeneities and intercommunications among distinct subtypes of B cells in the TME [21–23]. Based on increasing single-cell datasets, the foundational model has greatly accelerated the screening and verification of in silico perturbation and potential therapeutic targets for cancers [24, 25]. In this study, we conducted a comprehensive pan-cancer scRNA-seq and spatial transcriptomics sequencing (ST-seq) analyses of B cells using 668 samples from scRNA-seq (24 cancer types) and 112 samples from the ST-seq (12 cancer types), aiming to elucidate the spectrum of TIBs phenotypes and functionalities in both ICB responders and non-responders. The annotation of the ICB was derived from original papers and the TIDE score, which was broadly utilized to predict the ICB response [26]. The pan-cancer TCGA clinical dataset was utilized to analyze the clinical significance. We identified subtypes of TIBs and documented dynamic shifts in their proportion, transcriptomics features, pseudo-time trajectory, spatial distribution heterogeneity, and clinical significances. Plasma cells and activated B cells were enriched in responders, which was opposite to naïve B cells and memory B cells. Pan-cancer gene expression analyses revealed that antigen presentation, humoral immune response, and negative regulation of B cell apoptosis were consistently enriched in responders of distinct cancers. Pan-cancer WGCNA analyses identified 9 gene modules with significant cancer type enrichment and clinical association. B cell proportion-based NMF analyses [27] identified that c1_Stressed Plasma B-JCHAIN-enriched TIME-Plasma and c0_Atypical Memory-NR4A2 cell-enriched TIME-Memory were enriched in responders and were associated with reduced B cell apoptosis, higher TIDE score, and better survival in several cancers. Pan-cancer pseudo-time analyses revealed two major differentiation lineages with distinct ICB responses relationships and the pseudo-time heterogeneity of plasma cell subsets in distinct cancers. Integrated analyses of scRNA-seq and ST-seq revealed that B cell subsets derived from responders and non-responders were enriched in distinct histology structures in the TME. Plasma cells, memory B cells, and activated B cells from responders were preferred to be colocated. Utilizing corresponding TCGA datasets, the correlation between survival and the infiltration of B cell subsets of distinct ICB response degrees was revealed. Finally, based on the Geneformer foundational model structure [24], we successfully constructed the ICB response Geneformer and in silico knocked out all genes in the pan-cancer B cell atlas. Thirteen shared M-genes (monotonical genes), which were associated with the B cell state transition from non-responders to responders after in silico perturbation, were identified. These identified genes were significantly enriched in responders or non-responders and associated with the TIDE score and several known ICB target genes. The knowledge derived from these findings holds tremendous potential for clinical applications, including the development of more effective therapeutic strategies and personalized treatment approaches in cancer immunotherapy. Results The B cell subpopulations landscape varies significantly among cancers and ICB response groups We collected immune microenvironment scRNA-seq datasets of 25 cancer types with annotation of distinct ICB response (responders, Resp and non-responders, NR). These datasets were roughly annotated with several cell labels, including B cells, T cells, myeloid cells, and stromal cells, and it was found that B cell infiltration changed significantly among cancers (Fig. S1A) and response groups (Fig. S1B). Thus, pan-cancer B cells were selected for further analyses. All scRNA-seq datasets of B cells across 24 cancer types, consisting of 668 samples from 381 patients and 241,645 high-quality B cells, were identified (Figs. 1A, S1C, and supplementary table). The annotation of ICB response groups was acquired from the paper [11] and validated using the TIDE score (Figs. 1E and S2D) [28, 29]. Pan-cancer ICB response B cell profile at the single-cell resolution. A Schematics of pan-cancer ICB response single-cell transcriptome of B cells. Pan-cancer ST-seq datasets were downloaded for the analysis of spatial distribution heterogeneity, and pan-cancer TCGA datasets were downloaded for the analysis of the clinical significance. B Uniform manifold approximation of projection (UMAP) visualization of 24 B cell Seurat clusters. C Dot plot for the expression of marker genes in major B cell subsets. Colors represent maximum-normalized mean expression of marker genes, and the size represents the percentage of cells expressing these genes. D Heatmaps showing the Ro/e index of B cell major clusters in distinct cancers and between responders and non-responders. Ro/e index > 1.5 (+ +) indicates that the cluster is preferred to distribute in the corresponding tissue. Hierarchical clustering based on cosine distance is applied for rows and cols. E The box plot showing the expression level of the TIDE score which was utilized to predict the ICB response in cancers between responders (Resp) and non-responders (NR) groups in this study To avoid the potential of circular analyses, we stratified all related analyses into two cohorts: Cohort A, comprising samples with clinically annotated response status from original publications; and Cohort B, comprising samples for which response status was inferred by the TIDE score. Cohort A comprised 480 samples (~ 70%) with clinically annotated response status from original publications, while Cohort B comprised 188 samples (~ 30%) for which response status was inferred by TIDE due to lack of explicit clinical annotations (Supplementary Table). We calculated the TIDE score level of the entire tumor microenvironment of distinct tumor types in the Cohort A to validate the property of the TIDE score (Fig. S2E). To further support the rationale for using TIDE as an inferential tool in Cohort B, we have implemented the following methodological changes. We calculated the AUC-ROC of TIDE scores in distinguishing clinical responders from non-responders within Cohort A. TIDE achieved an AUC-ROC of 0.819, demonstrating reasonable concordance with clinical annotations (Fig. S2F). This supports the rationale for using TIDE as an inferential tool in Cohort B, while acknowledging its imperfect performance. We collected B cells from both responders and non-responders in almost all cancer types (Fig. S1D). ST-seq datasets and TCGA clinical datasets of corresponding cancer types were also collected (Fig. S1E). Rigorous quality control (Fig. S1F–I) and harmony-based datasets integration were performed before further analyses. After the data integration [30], the batch effect from distinct cancer types and samples was properly eliminated (Fig. S2A), and 24 clusters were identified using the unsupervised clustering algorithm (Fig. 1B), each observed in multiple datasets. Based on canonical immune markers [9] (Figs. 1C, S2B, and C), we defined 6 major transcriptional states and 10 minor transcriptional states: naïve B cell (c2_ naïve B), plasma B cell (Conventional Plasma B cells: c5_Con Plasma B-MZB1, c18_Con Plasma B-PRDX4; IGKC-high Plasma B cells: c22_IGKC-high Plasma B-ENAM, c23_IGKC-high Plasma B-HBA2; MT1X-high Plasma B cells: c10_ MT1X-high Plasma B; Stressed Plasma B cells: c1_Stressed Plasma B-JCHAIN, c7_Stressed Plasma B-HSP90B1, c9_Stressed Plasma B-XBP1,c12_Stressed Plasma B-DUSP5, c20_Stressed Plasma B-IFITM1), memory B cell (Atypical Memory B cells: c0_ Atypical Memory B-NR4A2, c3_ Atypical Memory B-SPINK2; Resting Memory B cells: c4_Resting Memory B), proliferative B cell (c8_Prolifer B-TPSAB1, c11_Prolifer B-CCL4, c13_Prolifer B-LYZ, c15_Prolifer B-COX3, c16_Prolifer B-PTGDS, c17_Prolifer B-HBB), GC B cell (c14_GC B-RGS13, c19_GC B-MTRNR2L2, c21_GC B-LINGO1), and activated B cell (c6_Activated B). The pan-cancer atlas of B cell ICB response enabled us to systematically examine the heterogeneity of B cells across cancer types (Fig. S3A). The Ro/e index [3] was calculated to investigate the infiltration heterogeneity of B cells in cancers and response groups (Fig. 1D). Memory B cells and naïve B cells showed similar infiltration in distinct cancers. Proliferative B cells were significantly enriched in cancers, including SS, AML, ESCC, UVM, GBM, and MM. Plasma cells showed significantly higher infiltration in cancers, including CHOL, HNSC, ESCC, UVM, OV, STAD, PDAC, COAD, and PRAD. GC B cells were significantly enriched in cancers, including SS, KIRC, MEL, BLCA, and BRCA (Fig. 1D left). Furthermore, atypical memory B cells and resting memory B cells showed distinct infiltration across cancers, while conventional plasma cells, MT1X-high plasma cells, and stressed plasma cells showed similar infiltration across cancers (Fig. S3B). B cell subset-level heterogeneity was depicted through cancer type stratification based on subset proportions (Fig. S3C). Of note, several cancer groups, including ESCC and UVM group, CHOL and HNSC group, and COAD and PRAD group, exhibited similar B cell compositions and were clustered together, indicating common factors in shaping the B cell-associated anti-tumor immunity (Fig. S3C). It was also shown that naïve B cells were enriched in non-responders while activated B cells and GC B cells were enriched in responders (Figs. 1D right, S3E top, and F left). However, it was shown that IGKC-high plasma cells and other plasma subsets were enriched in distinct response groups (Fig. S3D, E bottom, and F right). The co-occurrence analysis showed that plasma cells and memory B cells were more negatively correlated in responders (Fig. S3G). We also showed the infiltration of B cells across cancer in distinct response groups (Fig. S4). Transcriptional reprogramming of B cell subpopulations across cancers and ICB response groups We systematically examined the transcriptional reprogramming of B cells in response to immune checkpoint blockade to elucidate consistent patterns of differential gene expression across diverse cancers. (Fig. S5A). We calculated the number of differentially expressed genes (DEGs) in 23 cancer types (Fig. S5B). Cancers, including BCC, BLCA, GBM, and PRAD, showed higher up-regulated DEG numbers, while BLCA and OV showed higher down-regulated DEG numbers, indicating that these cancer types were strongly affected between response groups. Jaccard indexes, which indicated the similarity of DEGs across cancers, were calculated, and it was shown that cancers including BCC, BRCA, PRAD, PDAC, GBM, BLCA, and MM had similar up-regulated transcriptional dynamics in responders (Fig. S5C). We then focused on genes that were monotonically correlated with ICB responses (Fig. S5D). DEGs that were differentially expressed in more than 11 caners were identified as M-DEGs (monotonical DEGs) [31]. We ranked the M-DEGs by the number of cancer types in which they were involved and determined the common M-DEGs shared by multiple cancer types. The analyses identified 44 up-regulated common M-DEGs and 16 down-regulated common M-DEGs (Fig. S5E). Gene ontology analyses further showed that up-regulated common M-DEGs were enriched in antigen presentation, MHC complex assembly, humoral immune response, and negative regulation of B cell apoptosis (Fig. S5F). The scRNA-seq-defined common M-DEGs represented genes that exhibit consistent patterns of differential expression in responders across diverse cancers. We also calculated DEGs of distinct B cell subsets in responders compared to non-responders (Fig. S6A). Proliferative B cells and GC B cells showed higher up-regulated DEG numbers, while GC B cells showed higher down-regulated DEG numbers, which suggested that GC B cells were more transcriptionally affected in distinct ICB groups (Fig. S6B). The Jaccard index analysis revealed that plasma cells and activated B cells share similar up-regulated transcriptome dynamics, as do memory B cells and naïve B cells (Fig. S6C left). Nearly all B cell subsets exhibited distinct down-regulated transcriptome dynamics (Fig. S6C right). M-DEG analyses among B cell subsets of distinct response groups were performed (Fig. S6D), and further gene ontology analyses of up-regulated M-DEGs showed that distinct B cell subsets exhibited common enriched pathways, including immunoglobulin-related defense response, ER (endoplasmic reticulum) stress response, and negative regulation of B cell apoptosis (Fig. S6F). We also performed the WGCNA analyses [32] to investigate the gene expression module across cancers between responders and non-responders (Fig. S7A). Nine modules were identified and differentially expressed in distinct response groups, B cell subsets, and cancers (Fig. S8B–F). The correlation of distinct modules showed that modules including SM1 and SM2 were negatively correlated with SM6 (Fig. S7G). SM1 and SM2 were enriched in plasma cells, while SM6 was enriched in memory B cells, which suggested their mechanism (Fig. S7D). Enriched signatures of each module were calculated (Fig. S7H). SM1 and SM7 showed similar enriched pathways, including aerobic respiration and oxidative phosphorylation, but were enriched in distinct response groups and B cell subsets. SM2 and SM9 both showed enriched pathways like response to ER stress and unfolded protein. However, SM9 was specifically enriched in apoptosis and showed higher expression in non-responders. We also calculated the Jaccard index of significantly enriched pathways of each module to illustrate their biological function similarity (Fig. S7I). To investigate the clinical significance of these modules, the Cox analyses of WGCNA modules using TCGA datasets were performed (Fig. S7J). The result showed that SM3, SM6, SM8, and SM9 showed both significantly positive and negative correlation with the survival in distinct cancers, while SM1, SM2, SM4, SM5, and SM7 were only significantly positively correlated with the survival of several cancers. Analyses of B cell subpopulations abundance reveal five TIME subtypes We reasoned that the variations of B cell subsets composition would partially reflect TIME (tumor immune microenvironment) heterogeneity and calculated the proportion of each B cell subset in each sample of distinct ICB response groups [27]. NMF (nonnegative matrix factorization) was applied to explore the TIME heterogeneity in all 668 samples (318 non-responders and 350 responders). To determine the optimal rank for NMF, we performed NMF to identify B cell subsets modules across ranks from 2 to 20. This process was repeated 20 times, and the frequency of co-occurrences of different B cell subsets in the same module was measured. The results indicated that B cell subsets grouped into 5 co-occurrence modules, and a rank of 5 would thus best describe the TIME heterogeneity (Fig. S8A–D). We then performed the NMF classification of all samples using a rank of 5, resulting in five distinct TIME subtypes. Each sample was assigned to a single TIME subtype (Fig. 2A). Analyses of B cell subpopulation abundance reveal five TIME subtypes. A NMF classification revealed patients with five distinct TIME subtypes, each enriched with distinct B cell subsets. Values in heatmap indicate the scaled proportion of each subset in B cells. Cellular modules corresponding to each TIME subtypes are shown on the right. B Bar plots showing the number and proportion of samples in each TIME subtypes or responders and non-responders. C The bar plot showing the proportion of samples in each TIME subtypes among distinct cancer types and the hierarchical clustering of distinct cancers based on the proportion of distinct TIME subtypes. The distance was calculated using the Euclidean, and the clustering was calculated using the ward.D2. D Bar plot showing the significance (p value) of the B cell apoptotic signature. The signature was enriched using intrinsic DEGs of each TIME. E Box plots showing the expression level of the B cell apoptotic score and the TIDE score of distinct TIME subtypes between responders and non-responders. A t-test was utilized to calculate the statistical significance (ns: p > 0.05; *: p < 0.05; **: p < 0.01; ***: p < 0.001; ****: p < 0.0001). F The comparison of up-regulated DEGs of TIME-Memory and TIME-Plasma. DEGs were calculated between responders and non-responders. Three DEGs groups were identified based on the comparison result. G The gene ontology result of three DEGs groups identified in the Fig. 2F. H Survival curves of specific signatures of TIME-Memory and TIME-Plasma in TCGA datasets. Signatures were consisted of significantly up-regulated DEGs (p value < 0.05 and log2Foldchange > 0.5). Scores of signatures were calculated using the AddModuleScore function Samples with each of the five TIME subtypes showed enrichment of a distinct module of B cell subsets. Samples within the first TIME subtype showed enrichment of naïve B cells and were designated as samples with TIME-Naïve. Samples within the second TIME subtypes exhibited high levels of memory B cell infiltration and were thus designated as samples with TIME-Memory. Partial samples within the third TIME subtypes showed enrichment of only one memory B cell subset (c3_Atypical Memory-SPINK2) but several proliferative B cells and were thus designated as samples with TIME-Prolifer. Samples within the fourth TIME subtypes showed enrichment of plasma cells and were thus designated as samples with TIME-Plasma. The fifth TIME subtypes showed enrichment of GC B cells and were thus designated as samples with TIME-GC (Fig. 2A). Activated B cells occurred in several TIMEs, which suggested that this B cell subset was an intermediate cell state during the ICB response [33]. Samples with different TIME subtypes exhibited distinct ICB response rates. Higher response rates were observed in TIME-Memory and TIME-Plasma, while lower response rates were observed in TIME-Naïve and TIME-GC (Fig. 2B). TIME subtype heterogeneity across cancers was shown (Fig. 2C left), and the Hierarchical clustering result was depicted through cancer type stratification based on subset proportions (Fig. 2C right). TIME-GC was exclusively detected in BLCA, KIRC, MEL, OV, and SS, whereas the remaining TIME subtypes exhibited a broader cancer type distribution. TIME-Memory samples were enriched in responders of NSCLC and THCA, while TIME-Plasma samples were enriched in responders of MM (Fig. S8E), which might be associated with their clinical survival. We then investigated intrinsic transcriptomic features of distinct TIME subtypes by calculating DEGs of each TIME subtype (Fig. S9A). TIME-GC showed higher up-regulated DEG numbers while TIME-Prolifer and TIME-Plasma showed higher down-regulated DEG numbers (Fig. S9B). TIME-Memory and TIME-Naïve showed similar DEGs (Fig. S9C). Gene ontology analyses of up-regulated DEGs among TIME subtypes were performed to clearly demonstrate biological functions. The TIME-GC was associated with innate immune response and autophagy. The TIME-Memory was enriched in both innate and adaptive immune responses. The TIME-Naïve was enriched in B cell activation, antigen presentation, and cell adhesion. The TIME-Plasma was enriched in metabolism processes, humoral immune response, and antigen presentation. The TIME-Prolifer was enriched in B cell activation and cell cycle transition (Fig. S9D). Surprisingly, TIME-Memory and TIME-Plasma showed no enrichment significance in the B cell apoptotic process compared to the rest of the TIME subtypes (Fig. 2D). Further analyses revealed that both TIME-Plasma and TIME-Memory samples exhibited significantly lower B cell apoptotic scores, particularly in responder samples (Figs. 2E top and S9E), which suggested a potential association between reduced B cell apoptosis and ICB responsiveness (Fig. S9G). The expression of the TIDE score, which indicates the ICB response among TIME subtypes of distinct ICB responses, also supported this conclusion (Figs. 2E bottom and S9F). The TIDE score of responders of TIME-Memory and TIME-Plasma increased compared to non-responders. The correlation of the expression level between the B cell apoptotic score and the TIDE score in distinct TIME subtypes was calculated (Fig. S9H top). All TIME subtypes except TIME-Naïve showed a negative correlation between these two scores. These two scores were negatively correlated in TIME-Plasma of responders, which was opposite to non-responders (Fig. S9H bottom). To further demonstrate differences in response to ICB blockade in TIME subtypes, we analyzed DEGs of TIME subtypes between distinct response groups (Fig. S10A, B). Although TIME-Plasma and TIME-Memory both showed association with ICB blockade response, there were few similarities between their DEGs (Fig. S10C). It was assumed that these TIME subtypes responded to the ICB blockade mediated by distinct signature pathways. We performed the gene ontology analyses of TIME subtypes between responders and non-responders, which showed that TIME-GC, TIME-Prolifer, and TIME-Naïve were all enriched in the B cell apoptotic process, while TIME-Plasma and TIME-Memory were enriched in response to ER stress, antigen presentation, and metabolic process (Fig. S10D). We tried to identify transcriptomic differences between TIME-Plasma and TIME-Memory (Fig. 2F). Further gene ontology analyses revealed that TIME-Plasma was specifically enriched in cell adhesion, antigen presentation, proliferation, and apoptosis, while TIME-Memory was specifically enriched in metabolic process and B cell activation. Shared DEGs were enriched in biological processes associated with the ER, and response to hypoxia (Fig. 2G). Utilizing TCGA datasets, it was revealed that specific signatures of TIME-Memory and TIME-Plasma were associated with better survival in several cancers (Fig. 2H). JCHAIN + Plasma cells in TIME-Plasma display ER stress-mediated anti-tumor immunity and apoptosis repression in ICB responders We wondered which B cell subtypes played a vital function in TIME-Plasma samples during ICB blockade. It was shown that c1_Stressed Plasma B-JCHAIN cells were significantly enriched in the TIME-Plasma (Figs. 2A, 3A, and S11A). Previous studies showed that JCHAIN + plasma cells were associated with better survival in intrahepatic cholangiocarcinoma [34]. In our study, c1_Stressed Plasma B-JCHAIN cells showed a higher TIDE score in responders (Fig. 3B). c1_Stressed Plasma B-JCHAIN cells are also more infiltrated in CC and MM, which corresponds to the result in Fig. 2H right (Fig. 3C). The transcriptomic dynamics of c1_Stressed Plasma B-JCHAIN cells between responders and non-responders were performed, which revealed that metabolic processes and apoptotic processes were repressed while response to ER stress and immunoglobulin-mediated immune response were induced in ICB responders (Fig. 3D–F). Transcriptomics features c1_Stressed Plasma B-JCHAIN cells in responders compared to non-responders among cancers. A The box plot showing the enrichment of c1_Stressed Plasma B-JCHAIN cells in distinct TIME subtypes. ANOVA was utilized to calculate the statistical significance (ns: p > 0.05; *: p < 0.05; **: p < 0.01; ***: p < 0.001; ****: p < 0.0001). B The box plot showing the expression level of the TIDE score in c1_Stressed Plasma B-JCHAIN cells between responders and non-responders. A t-test was utilized to calculate the statistical significance (ns: p > 0.05; *: p < 0.05; **: p < 0.01; ***: p < 0.001; ****: p < 0.0001). C Box plots showing the proportion of c1_Stressed Plasma B-JCHAIN cells in the CC (TCGA-CESC) and MM (TCGA-SARC) in the pan-cancer B cell scRNA-seq dataset. D The scatter plot showing DEGs of c1_Stressed Plasma B-JCHAIN cells in responders compared to non-responders. E The result of the signature enrichment of DEGs (p value < 0.05 and abs(log2Foldchange) > 0.5) of c1_Stressed Plasma B-JCHAIN cells. Size of points indicating the number of DEGs. F Box plots showing the expression level of several signatures of c1_Stressed Plasma B-JCHAIN cells between responders and non-responders. A t-test was utilized to calculate the statistical significance (ns: p > 0.05; *: p < 0.05; **: p < 0.01; ***: p < 0.001; ****: p < 0.0001). G The bar plot showing the proportion of c1_Stressed Plasma B-JCHAIN cells in responders and non-responder among distinct cancers. H The bar plot showing the number of DEGs detected in distinct types of cancers. DEGs were calculated by comparing the transcriptome of c1_Stressed Plasma B-JCHAIN cells between responders and non-responders in distinct cancers and comparing the overlapping of DEGs. I Heatmaps showing the proportion of shared up-regulated and down-regulated DEGs in distinct cancers. The Jaccard index was used to indicate the similarity. The Jaccard Index measures the similarity between two sets as the size of their intersection divided by the size of their union. J The bar plot showing the frequency of selected M-DEGs (monotonically differentially expressed genes, which were detected in more than 8 cancer types). K The bar plot showing the gene ontology result of DEGs identified in Fig. 3 J c1_Stressed Plasma B-JCHAIN cells also showed distribution heterogeneity across cancers in distinct response groups (Fig. 3G). c1_Stressed Plasma B-JCHAIN cells showed significantly higher infiltration in responders of AML, COAD, and HCC, as well as non-responders of BRCA (Fig. S11B). To further demonstrate its transcriptomic heterogeneity (Fig. S11C–D) and common DEGs across cancers (Fig. 3H–K). Jaccard index of DEGs across cancers revealed that cancers including BCC, BRCA, PRAD, MM, and THCA were similar in up-regulated DEGs, while BLCA, HCC, and NPC were similar in down-regulated DEGs (Fig. 3I). DEGs that were differentially expressed in more than 8 caners were identified as M-DEGs (Fig. 3J). Up-regulated M-DEGs were enriched in B cell immune response, while down-regulated M-DEGs were enriched in apoptotic processes (Fig. 3K). We also demonstrated the expression heterogeneity of several signatures across cancers (Fig. S11E). NR4A1 + Memory B cells in TIME-Memory display aerobic respiration and repressed antigen–MHC complex assembly in ICB responders Utilizing a similar analysis method, we investigated specific B cell subsets that were associated with the ICB response in the TIME-Memory. It was revealed that c0_Atypical Memory-NR4A2 cells specifically infiltrated in TIME-Memory samples (Fig. S12A–B). Previous studies showed that the NR4A2 + memory B cells contributed to the response of the anti-BAFF treatment in systemic lupus erythematosus (SLE) patients [35]. c0_Atypical Memory-NR4A2 cells showed more infiltration in responders (Fig. S12C). We further analyzed the transcriptional dynamics of c0_Atypical Memory-NR4A2 cells between responders and non-responders (Fig. S12D). The gene ontology analysis revealed that up-regulated genes were enriched in aerobic respiration and apoptotic processes in response to oxidative stress, while down-regulated genes were enriched in antigen–MHC complex assembly (Fig. S12E). Signature pathway analyses revealed that response to ER stress and apoptotic process were increased in responders (Fig. S12F). Above all, it was inferred that up-regulated cellular respiration induced oxidative stress and finally caused apoptotic processes c0_Atypical Memory-NR4A2 cells of responders. Pan-cancer distribution analysis demonstrated that c0_Atypical Memory-NR4A2 cells exhibited significantly higher infiltration in responders across over 50% of cancer types examined. Pan-cancer transcriptional dynamics of c0_Atypical Memory-NR4A2 cells between response groups were performed (Fig. S13B). The result revealed that BLCA, ESCC, and OV showed a higher number of up-regulated DEGs, and BLCA and OV showed a higher number of down-regulated DEGs (Fig. S13C). Jaccard index of DEGs across cancers revealed that cancers including COAD, BLCA, and THCA were similar in up-regulated DEGs, while COAD and THCA were similar in down-regulated DEGs (Fig. S13D). DEGs that were differentially expressed in more than 6 caners were identified as M-DEGs (Fig. S13E–F). Up-regulated M-DEGs were enriched in B cell activation, respiratory process, and negative regulation of inflammatory response, while down-regulated M-DEGs were enriched in antigen presentation and negative regulation of apoptotic processes (Fig. S13G). We also demonstrated the expression heterogeneity of several signatures across cancers (Fig. S13H). Pseudo-time trajectory of pan-cancer B cell subpopulations with distinct ICB responses To understand the differentiation trajectories of pan-cancer B cell subsets between responders and non-responders, the pseudo-time analysis of pan-cancer B cells between responders and non-responders was performed. The Slingshot analysis [36] revealed two main paths (Fig. 4A): all started with naïve B cells, followed by Memory B cells, with lineage 1 connected with activated B cells, proliferative B cells, and ending in plasma cells, lineage 2 ending in GC B cells. The distribution of the pseudo-time trajectory dynamic revealed that native B cells were located in the root while plasma cells were at the terminal state (Figs. 4B and S14A). We also demonstrated the pseudo-time dynamic between distinct response groups. Significant increases in pseudo-time were observed in naïve B cells and activated B cells of responders, indicating enhanced differentiation and activation. In contrast, memory B cells and plasma cells showed decreases in pseudo-time, indicating that these B cells transited to a less terminal differentiation stage with lower apoptotic signatures (Fig. 4C). We also showed the pseudo-time heterogeneity across cancers, which mainly resulted from the B cell composition differences (Figs. 4D and S14B). Furthermore, we revealed transcriptomic dynamics along the pseudo-time of distinct lineages and response groups (Fig. 4E). B cell cytotoxicity and TIDE score were increased while B cell exhaustion and apoptotic processes were decreased along the pseudo-time in lineage 1 compared to lineage 2. Responders showed a higher TIDE score and lower B cell apoptotic score along the pseudo-time. Pseudo-time trajectory of pan-cancer B cells and plasma B cell subsets. A Uniform manifold approximation of projection (UMAP) visualization of 6 B cell subsets and its pseudo-time trajectory lineages identified by the Slingshot pipeline. B The feature plot of the Slingshot pseudo-time. The root of the trajectory started from the naïve B cells. C The box plot showing the Slingshot pseudo-time of distinct B cell subsets between responders and non-responders. A t-test was utilized to calculate the statistical significance (ns: p > 0.05; *: p < 0.05; **: p < 0.01; ***: p < 0.001; ****: p < 0.0001). D The box plot showing the Slingshot pseudo-time of distinct cancer types. E Line plot showing the correlation between several signatures as well as the TIDE score and the Slingshot pseudo-time in distinct lineages and response groups. F The bar plot showing the pseudo-time lineage diversity of distinct cancers between responders and non-responders. The pseudo-time lineage diversity was defined as the ratio of the number of pseudo-states to the number of unique B cell subsets minus one. G The heatmap showing the pseudo-time rank of distinct plasma cell subsets in distinct cancers and response groups. The rank was calculated based on the pseudo-time order in each cancer. H The box plot showing the scaled pseudo-time (defined as the ratio of the raw pseudo-time order to maximum of the raw pseudo-time order in each cancer) of distinct plasma cell subsets between responders and non-responders. A t-test was utilized to calculate the statistical significance (ns: p > 0.05; *: p < 0.05; **: p < 0.01; ***: p < 0.001; ****: p < 0.0001). I The line plot showing the dynamic of scaled pseudo-time of plasma cell subsets among distinct cancers. J Box plots showing the distribution standard error (calculated with the scaled pseudo-time of specific plasma cell subset) of distinct plasma cell subsets between responders and non-responders. A t-test was utilized to calculate the statistical significance (ns: p > 0.05; *: p < 0.05; **: p < 0.01; ***: p < 0.001; ****: p < 0.0001). K The heatmap showing the Jaccard index of DEGs of distinct pseudo-states in distinct cancers and response groups to indicate the transcriptomic similarity. Five meta-states were identified. L The bar plot showing enriched signatures of DGEs of meta-states identified in Fig. 4 K. M Box plots showing the enrichment of distinct plasma cell subsets in meta-states. ANOVA was utilized to calculate the statistical significance (ns: p > 0.05; *: p < 0.05; **: p < 0.01; ***: p < 0.001; ****: p < 0.0001) Since we have illustrated the main differentiation trajectory and the dynamics across cancers between response groups, we tried to further demonstrate the differentiation heterogeneity of plasma cells across cancers. We performed the trajectory analysis of plasma cells in distinct cancers using the Monocle pipeline [37, 38] (Figs. S15 to S16, the pseudo-time trajectory of plasma cells from distinct cancers and distinct response groups). First, we analyzed the heterogeneity in the distribution of trajectory states. Cancers of responders showed lower numbers of trajectory states compared to non-responders, indicating a small diversity of differentiation pathways shaped by the ICB response (Fig. S14C, D left, E top, and F left). In consideration of distinct plasma B cell subsets across cancers, we presented a pseudo-time lineage diversity calculated by the number of pseudo-time states versus the number of unique plasma B cell subsets (Fig. 4F bottom) [39]. Several cancers of responders showed fewer trajectory states compared to non-responders, as shown in Fig. S14C (Figs. 4F, S4D right, S14E bottom, and S14F right). We also analyzed the plasma cell subsets pseudo-time rank dynamic across cancers of distinct response groups. Conventional plasma cells were located in the first rank, and stressed plasma cells were located in the second rank. IGKC-high plasma cells and MT1X-high plasma cells were roughly located in the end rank state. In several cancers, including MEL and NPC, the rank position of IGKC-high plasma cells and MT1X-high plasma cells changed between responders and non-responders. The pseudo-time analysis of distinct plasma cell subsets across cancers also supported this conclusion (Fig. S14G). We further calculated the scaled pseudo-time of distinct plasma subsets between response groups (Fig. 4H). Significant increases in pseudo-time were observed in conventional plasma cells of responders, indicating an activated differentiation potential, while significant decreases in pseudo-time were observed in IGKC-high plasma cells and MT1X-high plasma cells of responders, indicating these cells were located in a less terminal state, which might be less exhausted and apoptotic. We also calculated the scaled pseudo-time heterogeneity of plasma cell subsets across cancers between response groups (Fig. 4I). More obvious differences of pseudo-time between response groups across cancers were shown in IGKC-high plasma cells and MT1X-high plasma cells compared to conventional plasma cells, which revealed that conventional plasma cells showed less heterogeneity between response groups across cancers. It was hypothesized that a particular subset of plasma cells would be more highly enriched in a specific pseudo-time state if the transcriptomic diversity were lower. We calculated the distribution standard deviation based on the composition of plasma cells among states, which revealed that conventional plasma cells showed lower standard deviation in responders, suggesting conventional plasma cells of responders were more enriched in a specific cell state (Figs. 4J and S14H). Since pseudo-time analyses of plasma cell subsets were separately performed across cancers, we then analyzed the transcriptomic similarity of distinct states across cancers, trying to find out pan-cancer pseudo-time states with common transcriptomic features (Fig. 4K). Five meta-states were identified, and the gene ontology analysis showed that meta-state_1 and meta-state_2 were enriched in ubiquitin–protein-mediated apoptotic process, meta-state_3 was enriched in B cell-mediated immune response, and meta-state_4 and meta-state_5 were enriched in response to ER stress and unfolded protein (Fig. 4L). meta-state_2 was more composed of pseudo-time states derived from non-responders, while meta-state_3, meta-state_34, and meta-state_5 were more composed of pseudo-time states derived from responders (Fig. S14I). The distribution of plasma cell subsets in meta-states revealed that conventional plasma cells were enriched in meta-state_3, stressed plasma cells were detected in all meta-states, and MT1X-high plasma cells and IGKC-high plasma cells were enriched in meta-state_2 (Fig. 4M). Pan-cancer network analyses reveal receptor–ligand interaction of B cells with distinct ICB responses The interaction strength between receptors and ligands among B cell subsets was supposed to mediate the differences in ICB response, and thus, we utilized the CellChat [40] to demonstrate the differences in the ligand and receptor interaction strength between response groups. Responders showed more interaction numbers but less interaction strength compared to non-responders, which indicated several novel interactions activated in ICB responders (Fig. S17A). We then analyzed the dynamics of interaction numbers and strength among B cell subsets. The number of interactions among plasma cells, memory B cells, and proliferative B cells, which played a vital part in ICB response, supported in previous analyses (Fig. 2), increased while the number of interactions among naïve B cells, GC B cells, and activated B cells decreased in responders (Fig. S17B–D). We analyzed the incoming and outgoing interaction strength of B cell subsets between responders and non-responders (Fig. S17E). GC B cells showed increased incoming and outgoing interaction strength in responders. Proliferative B cells, memory B cells, and naïve B cells showed decreased incoming and outgoing interaction strength in responders. Activated B cells and plasma cells showed increased outgoing interaction strength and decreased incoming interaction strength. We further examined the dynamic signatures across B cell subsets between response groups, which revealed that MHC-I was commonly enriched in responders of naïve B cells, memory B cells, plasma cells, and activated B cells, while APP was commonly enriched in non-responders of all B cell subsets (Fig. S17F). Previous studies have shown that enhanced antigen presentation by B cells resulted in tumor repression, suggesting a potential avenue of immunotherapy against cancers [41, 42]. The relative information flow of conserved pathways (Fig. S17G) and systematic analysis of signaling changes in B cell subsets (Fig. S17H) also supported this result. The outgoing signaling pattern of the MHC-I pathway increased in the plasma cells of responders compared to non-responders (Fig. S17H right). B cell subpopulations with distinct ICB responses occupy spatially distinct niches across cancers To investigate the spatial organization heterogeneity of B cell subsets correlated with the ICB response, we obtained spatial transcriptomics datasets across 14 cancer types, consisting of 112 samples derived from the CROST [43] database, and 284,427 high-quality spatial spots were identified (Figs. 5A, S18A, and S18B). We first integrated all ST-seq datasets with the harmony algorithm, and clusters were identified using unsupervised clustering. The batch effect of distinct cancers was eliminated properly (Fig. S18C). All pan-cancer spatial histology substructures were annotated (Fig. 5B) with selected marker genes (Fig. 5C) and signaling pathways enrichment (Fig. S18D). We then analyzed the distribution heterogeneity of histology substructures (Fig. S18E–F). Keratin and immune response-related structures are widely distributed across various cancers, highlighting the critical roles of tissue structure maintenance and immune response in the tumor microenvironment. Notably, distinct cancer-specific microenvironmental features are also evident: the enrichment of metabolic and catabolic structures in hepatocellular carcinoma (HCC), the overrepresentation of respiratory system-related pathways in kidney renal clear cell carcinoma (KIRC), and the prominence of synapse organization in glioblastoma (GBM). These findings underscore the unique biological landscapes that characterize different cancer types. Finally, we showed the transcriptomic heterogeneity of each histology substructure utilizing DEGs calculation (Fig. S18G) and gene ontology analyses (Fig. S18H). Above all, we constructed a pan-cancer ST-seq atlas and illustrated its transcriptomics features, followed by integrating analyses using pan-cancer scRNA-seq datasets. Integrative spatial transcriptomics datasets and single-cell RNA datasets of pan-cancer B cells. A Schematics of integrative analyses of pan-cancer B cells spatial transcriptomics and single-cell RNA datasets. B Uniform manifold approximation of projection (UMAP) visualization of 24 B cell clusters annotated based on their DEGs and enriched signatures. C Dot plot for the expression of top3 marker genes of distinct histology structures in the spatial transcriptomics dataset. Colors represent maximum-normalized mean expression of marker genes, and the size represents the percentage of cells expressing these genes. D Feature plots showing the predicted infiltrating percent of distinct B cell subsets in responders and non-responders. E Dot plot for the infiltrating level of distinct B cell subsets in distinct histology structures of the spatial transcriptomics dataset. Colors represent maximum-normalized mean expression of marker genes, and the size represents the percentage of cells expressing these genes. F Dot plot for the infiltrating level of distinct plasma B cell and memory B cell subsets in distinct histology structures of the spatial transcriptomics dataset. Colors represent maximum-normalized mean expression of marker genes, and the size represents the percentage of cells expressing these genes. G Heatmap showing the co-occurrence (infiltration level correlation) of B cell subsets derived from responders and non-responders in the ST-seq dataset. The correlation was calculated based on the spearman correlation. H Heatmap showing the co-occurrence (infiltration level correlation) of B cell subsets in distinct histology structures and response groups of the ST-seq dataset. The correlation was calculated based on the spearman correlation Utilizing both pan-cancer scRNA-seq datasets and ST-seq datasets, we performed the CARD-based deconvolution analysis [44] to demonstrate the spatial distribution heterogeneity of B cell subsets of distinct response groups. Each ST-seq dataset was deconvoluted with corresponding scRNA-seq datasets annotated with B cell subsets and other cells to ensure the accuracy of the deconvolution. It was revealed that B cell subsets from distinct response groups showed distinct spatial distribution preference (Fig. 5D–F). The immune response substructure showed enrichment of B cell subsets of both response groups. Other histology substructures were enriched in several specific B cell subsets, and B cell subsets of distinct response groups showed distinct spatial distribution, which indicated that ICB response was associated with the migration of B cells (Fig. 5E–F). By calculating the spatial co-occurrence of B cell subsets (Fig. 5G), it was revealed that plasma cells, memory B cells, and activated B cells of responders were positively correlated, which suggested that ICB mediated the interaction and differentiation among these B cell subsets. To validate that the positive correlations between responder-derived B cell subsets (plasma cells, memory B cells, and activated B cells) in Fig. 5G were not due to random chance, we performed spot-label permutation tests (n = 1000). Spot labels for each cell type proportion were randomly shuffled while preserving the spatial structure of other subsets, and Spearman correlations were recalculated. The observed correlations (ρ = 0.67–0.78) significantly exceeded all null distributions (empirical P < 0.001 for all pairwise comparisons), confirming that the spatial co-enrichment of these subsets is statistically robust and not attributable to random spatial patterns (Fig. S19A). It was also validated by DEGs of these B cell subsets which revealed that the DEGs levels of these subsets was positively correlated (Fig. S19B). To statistically validate the spatial patterns inferred from deconvolution, we performed global Moran’s I analysis with Monte Carlo permutation tests (n = 999) across 336 tumor cell type combinations. Responder-derived B cell subsets (plasma cells, memory B cells, activated B cells) exhibited significant positive spatial autocorrelation (median Moran’s I = 0.25, P < 0.001 for 95% of comparisons), confirming that these cells form spatially organized aggregates rather than random distributions (Fig. S19C). Naïve B cells of both responders and non-responders showed a positive correlation, indicating ICB did not influence the spatial distribution of naïve B cells. We further calculated the correlation in each histology substructure (Fig. 5H). It was shown that B cell subsets showed negative correlation in substructures including muscle, renal system, and immune response-related structure, while showing positive correlation in substructures including melanin metabolic, gastrointestinal epithelium, and metabolic and catabolic substructures. Development of the ICB response geneformer model for in silico screening of genes involved in ICB response state transition To systematically investigate the clinical significance of B cell subsets of distinct response groups, pan-cancer TCGA datasets were collected for Cox analyses. It was shown that the same B cell subset from responders or non-responders exhibited similar clinical correlation with the survival (Fig. 6A). Notably, the same B cell subtype, whether derived from responders or non-responders, exhibited a consistent association with survival outcomes within a given cancer type (Fig. 6B). Interestingly, this association was context-dependent: a specific B cell subtype could display either a positive or negative correlation with survival across different cancer types (Fig. S20). Clinical correlation of pan-cancer B cells, ICB response Geneformer construction, and in silico perturbation stats dynamic screening. A The cox analysis of the clinical correlation of B cell subsets of distinct response groups. The DEGs of B cell subsets of distinct response groups were used for calculating the B cells subsets scores (p value < 0.05 and log2Foldchange > 0). B Survival curves of the infiltration of B cells subsets of distinct response groups. C Schematics of the pipeline of the construction of the ICB response Geneformer, fine-tuning, and in silico perturbation screening processed in each cancer type separately. D Heatmaps showing the proportion of shared response genes and non-response genes in distinct cancers. The Jaccard index was used to indicate the similarity. The Jaccard Index measures the similarity between two sets as the size of their intersection divided by the size of their union. E Left, the bar plot showing the number of response genes and non-response genes detected in distinct types of cancers. Right, the bar plot showing the enriched signatures of M-genes. M-genes were defined as response genes and non-response gene detected in more than 16 cancer types. F Box plots showing levels of shared response gene score and non-response gene score between responders and non-responders. A t-test was utilized to calculate the statistical significance (ns: p > 0.05; *: p < 0.05; **: p < 0.01; ***: p < 0.001; ****: p < 0.0001). G Line plots showing the correlation between shared response gene score as well as non-response gene score and the TIDE score. Significances were calculated with the t-test method and the correlation was calculated with the spearman method. H Line plots showing the correlation between shared response gene score as well as non-response gene score and the TIDE score in responders and non-responders. Significances were calculated with the t-test method and the correlation was calculated with the spearman method. I Line plots showing the correlation between shared response gene score as well as non-response gene score and the known ICB target score (left)and related genes (right) in responders and non-responders. Significances were calculated with the t-test method, and the correlation was calculated with the spearman method Utilizing the pan-cancer ICB response B cell atlas, we further constructed an ICB response Geneformer model [24] for further in silico perturbation of all genes to identify candidate genes that were associated with the B cell states transition from non-responders to responders. The foundation model was trained on the pan-cancer dataset and fine-tuned in each cancer type (Fig. 6C). All genes were in silico perturbed in distinct cancers, and the similarity of cell states (the cosine value of the cell embedding) after the perturbation was calculated to quantify the state transition toward responders. Only the perturbation of a small proportion of genes could significantly result in the cell state transition (Fig. S21A). If the cosine value was larger than 0, it means B cells transited toward responders after the knockout perturbation (annotated as Response genes). If the cosine value was smaller than 0, it means B cells transited toward non-responders after the knockout perturbation (annotated as non-response genes) (Fig. S21B). The proportion of these two kinds of significantly perturbed genes was similar in distinct cancers (Fig. S21C). The B cell state transition after in silico perturbation in distinct cancers was systematically shown in Fig. S21D. Compared to nonsignificant gene perturbations, significant gene perturbations caused more dramatic changes in the state of B cells (Fig. S21E). Since we have identified genes that could cause the B cell state transition between responders and non-responders in distinct cancers. We also calculated the Jaccard index of significantly perturbed genes to illustrate their similarity (Fig. 6D). MM and NSCLC showed similar response genes, while COAD, HCC, and NPC showed similar response genes. A large proportion of cancer types showed similar non-response genes. Seven response genes that caused B cells to respond after the knockout, and 4 non-response genes that caused B cells to tend to respond after the knockout were identified in 21 cancers. Genes that were identified in more than 16 cancer types were defined as M-genes (monotonical genes) (Fig. 6E left). Gene ontology analyses showed that response M-genes were enriched in B cell apoptotic process, antigen presentation, and cell killing, while non-response M-genes were enriched in negative regulation of apoptotic process and several processes associated with proliferation (Fig. 6E right). This suggested that the overactivation of antigen presentation and following immune response and apoptotic processes reduced the ICB response of B cells, while persistent and proper cell proliferation could maintain the proportion of B cells and their overall biological function [45]. We selected M-genes that were detected in 21 cancers for further validation. It was shown that the shared response gene score was significantly higher in non-responders, and the shared non-response gene score was significantly higher in responders (Fig. 6F). Further analyses showed that the shared response gene score was negatively correlated with the TIDE score, which was opposite to the shared non-response gene score (Fig. 6G). The above correlations were separately calculated in responders and non-responders. Of note, there was no significant correlation between shared response gene score and TIDE score in non-responders. We next investigated the correlation between these two kinds of gene scores and several known ICB target genes, including PDCD1, CD274, TIGIT, LAG3, HAVCR2, and CTLA4. It was shown that the shared response genes score was negatively correlated with the ICB target genes score in responders, which was opposite to non-responders (Fig. 6I left). Heterogeneity appeared when calculating correlation with separate genes (Figs. 6I right and S22). Discussion The pivotal role of TIBs in sculpting the TME, influencing cancer progression, and determining treatment responses has been widely acknowledged. However, our understanding of their variability and adaptability across different cancer types and their impact on immunotherapy remains unclear. To address this gap, we compiled an extensive dataset of tumor specimens that enabled us to comprehensively explore the heterogeneity of TIBs across distinct cancer types between responders and non-responders to the ICB therapy. Recent pan-cancer B cell atlases by Yang et al. [11], Fitzsimons et al. [9], and Ma et al. [10] have advanced our understanding of B cell heterogeneity across human cancers. However, these studies primarily focused on cataloging phenotypic diversity without systematically dissecting ICB response-associated heterogeneity, were limited in cancer type coverage, or lacked spatial and immunotherapy response dimensions. Notably, none incorporated deep learning-based approaches for therapeutic target screening. Our study addresses these gaps by integrating single-cell and spatial transcriptomics with Geneformer-based in silico perturbation within an ICB-centric framework, providing a clinically oriented resource for precision immunotherapy. We integrated transcriptional profiles of TIBs from diverse cancer types, aiming to demonstrate shared patterns of cellular composition and gene expression dynamics between distinct ICB response groups. Utilizing these analyses, we constructed the pan-cancer ICB response B cell atlas and identified several B cell subsets that were consistently enriched in responders or non-responders among distinct cancer types. We also identified shared gene expression patterns of B cells associated with antigen presentation and negative regulation of B cell apoptosis in responders of distinct cancers. Importantly, our research demonstrated the heterogeneity of TIBs across cancers and shed light on specific TIB subsets that exhibited significant shifts in both proportion and transcriptome in responders compared to non-responders. Based on previously published research [27], we performed B cell proportion-based NMF analyses and identified five distinct TIMEs across cancers in which TIME-Plasma and TIME-Memory were infiltrated with specific TIB subsets (TIME-Plasma samples were infiltrated with c1_Stressed Plasma B-JCHAIN cells and TIME-Memory samples were infiltrated with c0_Atypical Memory-NR4A2 cells), enriched in responders, and correlated with better survival in several cancers mediated through distinct signatures. TIME-Memory from responders were associated with metabolic process, B cell immune response, and negative regulation of apoptosis. TIME-Plasma from responders were associated with B cell proliferation, humoral immune response, and apoptosis. Utilizing pseudo-time analyses, we observed significant dynamic changes in the kinetic profiles of TIBs. Two distinct differentiation pathways (one ended with plasma cells and the other ended with GC B cells), which showed opposite correlations with B cell apoptosis and ICB response, were identified. One pathway ended in the plasma cells, and the other pathway ended in the GC B cells. Further pseudo-time analyses revealed the differentiation heterogeneity of distinct plasma cell subsets across cancers. Pan-cancer pseudo-time analyses identified five meta-states with transcriptional features and ICB response enrichments. Conventional plasma cells were enriched in B cell-mediated immunity while stressed plasma cells were enriched in response to stress and apoptosis. TIBs migrated within the TME and played a vital part in the anti-tumor immune response mediated by cytokines and chemokines [46]. Integrated pan-cancer ST-seq and scRNA-seq datasets were utilized to demonstrate the spatial distribution heterogeneity of B cells subsets from responders and non-responders. Specific B cell subtypes derived from distinct response groups showed distinct spatial distribution. Plasma cells, memory B cells, and activated B cells from responders showed positive co-occurrence which suggested their shared functions in the ICB response. Although scRNA-seq and ST datasets were cancer-type-matched, they derived from independent patients and platforms. We mitigated this through CARD’s spatial correlation modeling, Harmony batch correction, and per-cancer deconvolution. Nevertheless, inferred proportions remain probabilistic estimates requiring validation by matched scRNA-seq/ST or single-cell-resolution technologies. Utilizing the pan-cancer TCGA datasets, the clinical heterogeneity of TIBs subsets in distinct cancers was revealed. B cells from responders and non-responders may have opposite relationship with the survival. The in silico perturbation approach offers significant advantages in terms of high-throughput screening capability and cost-effectiveness, enabling systematic evaluation of thousands of genes across multiple cancer types without the logistical constraints of experimental validation. Using the pan-cancer ICB response B cell single-cell atlas and the foundation model Geneformer, we constructed a novel ICB response Geneformer and in silico perturbed all genes to screen genes that were correlated with the B cell state transition from non-responders to responders. This process could accelerate the screening of ICB response targets and be applied in other situations. Several limitations should be acknowledged. First, integrating scRNA-seq datasets from diverse sources introduced technical heterogeneity from variations in sample processing and sequencing platforms, despite batch effect correction. Second, our findings rely on computational inference; functional validation of the M-genes and mechanistic understanding of how reduced B cell apoptosis promotes ICB response require experimental verification. Third, spatial transcriptomics data were predominantly from the 10X Genomics platform at spot-level resolution. Fourth, the Geneformer enabled high-throughput screening, but needs experimental confirmation. Above all, this research firstly constructed a pan-cancer B cell atlas correlated with the ICB response and demonstrated the heterogeneity in cell composition, transcriptomes, spatial distribution, and clinical significance. Utilizing existing foundational model structures, our research identified several genes that were associated with the B cell state transition. Methods ScRNA-seq datasets collection In this study, we utilized previously published scRNA-seq datasets. Transcriptome data for B cells in 668 samples from 381 individuals across 37 scRNA-seq datasets were obtained. The pan-cancer ICB response B cell atlas consisted of 24 cancer types: acute myeloid leukemia (AML) [47, 48], basal cell carcinoma (BCC) [49], B cell lymphoma (BCL) [18], bladder cancer (BLCA) [50, 51], breast cancer (BRCA) [19, 52], cervical cancer (CC) [20], cholangiocarcinoma (CHOL) [53], colorectal cancer (COAD) [21, 22], esophageal squamous cell carcinoma (ESCC) [23], glioblastoma (GBM) [54], hepatocellular carcinoma (HCC) [55, 56], head and neck squamous cell carcinoma (HNSC) [57], kidney renal clear cell carcinoma (KIRC) [58, 59], melanoma (MEL) [60, 61], multiple myeloma (MM) [62, 63], nasopharyngeal carcinoma (NPC) [64], non-small cell lung cancer (NSCLC) [65–67], ovarian carcinoma (OV) [68, 69], pancreatic ductal adenocarcinoma (PDAC) [70–72], prostate adenocarcinoma (PRAD) [73–75], synovial sarcoma (SS) [76], stomach adenocarcinoma (STAD) [77], thyroid carcinoma (THCA) [78, 79], and uveal melanoma (UVM) [80]. A detailed description of data availability, including data sources and accession numbers of scRNA-seq datasets, is provided in Supplementary Table. We first collected all datasets of the whole cancer microenvironment, which included T cells, NK cells, stromal cells, myeloid cells, and B cells. ICB response groups were annotated based on the known description in the original research papers or the expression level of the TIDE score. Each dataset was roughly annotated by distinct cell labels, including T_NK, stromal, myeloid, and B. B cell barcodes were selected for further analyses in this study. To avoid the potential of circular analyses, we stratified all related analyses into two cohorts: Cohort A, comprising samples with clinically annotated response status from original publications; and Cohort B, comprising samples for which response status was inferred by the TIDE score. Cohort A comprised 480 samples (~ 70%) with clinically annotated response status from original publications, while Cohort B comprised 188 samples (~ 30%) for which response status was inferred by TIDE due to lack of explicit clinical annotations (Supplementary Table). ScRNA-seq data integration and quality control ScRNA-seq data integration was performed in the preprocessing of datasets of each cancer type and following analyses, which integrated B cells scRNA-seq datasets from distinct cancers. In the preprocessing, several datasets of one cancer were collected, and Harmony was used to integrate all the datasets for the annotation and selection of B cells. We calculated a PCA matrix with 30 components using HVGs, which was then input into the HarmonyMatrix() function from the Harmony R package. We specified “sample” as the technical covariate for batch correlation. After the selection of B cell barcodes from distinct datasets, the Harmony and the same parameter were utilized to combine all B cells and eliminate the batch effect. After Harmony, barcodes from distinct cancers and samples were integrated properly. We calculated detected genes (nFeature_RNA) and transcript count (nCount_RNA) in distinct cancers. Several samples in the SS were from the SMART2-seq platform and showed distinct detected gene counts and transcript counts. The composition of patients and samples was calculated. We collected scRNA-seq datasets in which low-quality barcodes and double drops had already been removed based on previous published research. Any further quality control processes were not performed. Clustering and annotation B cell datasets underwent normalization using the Seurat NormalizeData function, with default parameters. We identified the top 2000 highly variable genes (HVGs) for principal component analysis (PCA). Selection of principal components (PCs) was performed on default parameters. Using the FindNeighbors and FindClusters functions in the Seurat R package, we identified clusters for further B cell subsets annotation. The uniform manifold approximation and projection (UMAP) was used for visualization. The annotation of resulting clusters into major cell types and minor cell types relied on the expression patterns of canonical marker genes, including pan-B cells (CD19, MS4A1), naïve B cells (IL4R, TCL1A, FCER2, FCMR, SELL), pan-memory B cells (CD27, LY86, BLK, LTB, BANK1, CCR7, CHMP1B, NFKBID), atypical memory B cells (DUSP4, CD82, CD86, ISG15, CAPG, COTL1, IFITM1, DRAP1, TNFRSF13B, LGALS9, SHFL, PLSCR1, MX2, IFI6, IFI44L), activated B cells (CD69, CD83, NR4A2), HLA marker genes (HLA-DPB1, HLA-DRA, HLA-DPA1), germinal center marker genes (SUGCT, BCL6, SSBP2, STAG3, RGS13, LCK, MYO1E, IRAG2, LAT2, RRAS2, MARCKSL1, SERPINA9, PRPSAP2, LMO2, CD22), proliferation marker genes (H4C3, VPREB3, STMN1, HMGB2, EIF6, PSMA7, CRIP1, PTMA, TYMS, TUBB, AURKB, UBE2C, MKI67, TUBA1B), metallothionein marker genes (MT1X, MT2A, MT1D, MT1F), immunoglobulin (IGKC, IGHM, IGHD, IGHA1, IGHA2, IGHG1, IGHG2, IGHG4, IGHGP, IGLC2, IGLC3), plasma cell marker genes (DERL3, FKBP11, PRDX4, TMED2, DPP7, FIS1, ISG20, EZR, PSME2, PRDM1, MCL1, MZB1, XBP1, VIM, SSR4, JCHAIN, JUN, CD38, SDC1), stressed cell marker genes (FOS, DNAJB1, DUSP1, ZFAND2A, HSPA1B, HSPA1A, HSPB1, HSPA6). DEGs analyses and functional enrichment Differential gene expression of cell populations in scRNA-seq data, as well as substructures in ST-seq data with biological significance, was calculated via the FindMarkers function of the Seurat package. Differential gene-enriched signatures were calculated with clusterProfiler, org.Mm.eg.db, and AnnotationHub R packages. The expression level of interesting spatial signaling pathways was also calculated by the AddModuleScore function of the Seurat package to imply restricted distribution or expression patterns of a specific gene set obtained from the Gene Ontology database. WGCNA analyses Weighted gene co-expression network analysis (WGCNA) was performed using the WGCNA R package. We analyzed to delve into gene modules significantly correlated with the clinical characteristics of the ICB response. Initially, hierarchical clustering analysis was employed to weed out any outlier samples. Next, we utilized the pickSoftThreshold function from the package to select the appropriate soft threshold beta. This process generated an adjacency matrix, which was then transformed into a topological overlap matrix (TOM). Through various TOM measures, genes exhibiting similar expression patterns were allocated into distinct modules via average linkage hierarchical clustering. We also calculated the correlation between these modules. We calculated the signature enrichment of distinct modules and utilized Cox analyses to demonstrate their transcriptomic features and relationship with clinical output. NMF analyses To dissect the heterogeneity of tumor B cell microenvironment in patients and reveal different immune-related patterns, we classified samples into five groups based on the percentage of each B cell Seurat cluster in all B cells using the NMF package. The matrix of percentage of B cell Seurat clusters in each sample was used as the input for the NMF analysis. The NMF algorithm grouped samples into clusters depending on the parameter rank k. To select the proper k, the NMF was performed per rank from 2 to 20. This process was repeated 200 times, and cophenetic correlation coefficients were calculated to assess how similar these results were. We measured the frequency of co-occurrences of distinct B cell subsets in the same NMF module during the 200-time NMF classification. We found that B cell subsets grouped into 5 co-occurrence modules, indicating a rank of 5 would best describe the TIME heterogeneity. Then, rank 5 was put into the NMF function with the matrix, and the extractFeatures function was used to extract k cell type modules from the result. We used the predict function to group samples into 5 clusters. Each cluster was matched with one cellular module, which presented its immune-related pattern. The relative contribution of each B cell subset to each TIME subtype was visualized with the heatmap. Each sample was assigned to a single TIME subtype. Pan-cancer pseudo-time trajectory inference of B cell subsets The R package Slingshot was used to define computationally imputed pseudo-time trajectory in B cell subsets. The analyses were performed for the whole B cell population. PCA-based dimension reduction was performed on DEGs of each B cell subset, followed by two-dimensional visualization on UMAP. Graph-based clustering identified additional heterogeneity of B cell subsets. The UMAP matrix was fed into Slingshot, considering naïve B cells as a root when calculating the trajectories and the pseudo-time. Two main lineages were identified after the Slingshot analysis. We compared the pseudo-time across distinct B cell subsets and distinct cancers od both response groups. We also calculated the correlation between the pseudo-time and signatures expression in distinct differentiation lineage. The inferred pseudo-time trajectory of plasma cell subsets was computed using the Monocle software, which was employed to recover dynamic temporal processes through single-cell gene expression kinetics. We performed Monocle on each cancer type of distinct response groups separately to illustrate differences from both cancer type perspective and ICB response perspective. Conventional plasma cells were set as root cells. We compared the trajectory structures across cancers of distinct response groups to demonstrate their differentiation lineage similarities. We calculated the scaled pseudo-time to demonstrate the differentiation rank among plasma cell subsets. We also demonstrated the enrichment of plasma cell subsets in each pseudo-time state to show their differentiation lineage diversity. To illustrate transcriptomics features of pseudo-time states in distinct samples, we calculate DEGs of each state and calculate the similarity of DEGs using the Jaccard index. States with similar transcriptomics features were significantly clustered and annotated with several pan-cancer meta-states. Transcriptomics features and plasma cell subsets heterogeneity were revealed. Gene regulatory network analysis We used the pyscenic algorithm to identify gene regulatory networks (regulons) activated in each B cell subsets in distinct response groups across cancers with raw count matrix as input. The co-expression network was calculated by GRNBoost2 and the regulons were identified by RcisTarget. Next, the regulon activity for each B cell subsets, distinct cancer, and response groups was scored by AUCell. For each cluster, regulons were ranked by regulon specificity score (RSS) by using the R function calcRSS. Finally, we calculate the activity correlation of distinct regulons to reveal their biological function similarity. Cell–cell communication inference using CellChat CellChat was used to infer the communication among B cell subsets between response groups across cancers. Based on gene expression of receptors and ligands in the data and a curated database of pathways, CellChat computed the communication probability between various receptor–ligand pairs. CellChat also provided ways to aggregate this information and to visualize the inferred cell–cell communication networks. Following the CellChat analyses of each response group, we calculated differences in the number of interactions and interaction strength between responders and non-responders. Several signatures that were enriched in each group was also identified. Integrative spatial transcriptomics analyses We obtain ST datasets of distinct cancer types from the CROST database [43] and the Gene Expression Omnibus including. The gene expression count matrices and corresponding histology images for the ST datasets were downloaded and processed using the R package Seurat. All ST datasets were integrated using the harmony pipeline with default parameters. After integration, the batch effect among samples were processed properly. ST datasets underwent normalization using Seurat NormalizeData function, with default parameters. We identified the top 2000 highly variable genes (HVGs) for principal component analysis (PCA). Selection of Principal Components (PCs) was performed on default parameters. Using FindNeighbors and FindClusters functions in the Seurat R package, we identified clusters for further histology annotation. The annotation of resulting clusters into histology substructures relied on the expression patterns of canonical marker genes, including renal system (STC1, NPR3, STK39), respiratory system (SFTPD, NKX2-1, CTSH), synapse organization (GAP43, GPM6A, TUBA1A), metabolic and catabolic (GC, APOA1, APOB), hormone secretion (PTPRN2, TRPV6,INS), muscle (TTN, ACTA1, TNNI1), keratin (SFN, KRT17, KRT5), melanin metabolic (PMEL, TYR, DCT), prostate gland epithelium (NKX3-1, HOXA13, AR), gastrointestinal epithelium (TFF1, MUC13, TFF3), and immune response region (CD47, HMGB1, MAPKAPK2). DEGs and enriched pathways were calculated to demonstrate the transcriptional features of each histology substructure. The histology composition of each cancer was calculated to demonstrate the histology heterogeneity. For cell type deconvolution, we employed CARD (v1.1) to infer the proportions of B cell subsets and other cell types within each ST spot. To minimize cross-sample reference bias, scRNA-seq reference data were strictly matched by cancer type; pan-cancer mixed references were not used. For each cancer type, all scRNA-seq samples were merged and batch-corrected using Harmony (as described in the scRNA-seq integration section). B cell subpopulations were annotated using canonical marker genes and subsequently combined with ICB response status (responder vs. non-responder) to generate composite labels (e.g., seurat_clusters_response), enabling the deconvolution of responder-derived and non-responder-derived B cell subsets simultaneously. For each cancer-type-matched ST sample, a CARD object was created using the following parameters: sc_count (raw scRNA-seq count matrix), sc_meta (single-cell metadata containing composite cell type labels), spatial_count (raw ST count matrix), and spatial_location (spot spatial coordinates). The conditional autoregressive deconvolution was performed using CARD_deconvolution() with ct.varname = "seurat_clusters_response", sample.varname = "orig.ident", minCountGene = 100, and minCountSpot = 1. The output proportion matrix (Proportion_CARD) was used for downstream spatial co-occurrence and histology structure enrichment analyses. To validate that the positive correlations between responder-derived B cell subsets (plasma cells, memory B cells, and activated B cells) were not due to random chance, we performed spot-label permutation tests (n = 1,000). Spot labels for each cell type proportion were randomly shuffled while preserving the spatial structure of other subsets, and Spearman correlations were recalculated. To provide an independent validation not reliant on deconvolution proportions, we identified top differentially expressed genes (DEGs, adjusted p value < 0.05 and average log2foldchange > 1) for each responder-derived B cell subset from scRNA-seq data, calculated module scores for these gene sets in ST spots using AddModuleScore, and assessed correlations between these transcriptional signatures. To assess whether B cell subsets exhibited non-random spatial organization, we calculated global Moran’s I for the inferred proportions of each cell type across ST spots. For each sample and cell type, a spatial weights matrix was constructed using distance-based neighbors, accounting for the hexagonal Visium grid geometry. Row-standardized weights (style = “W”) were applied using nb2listw. Global Moran’s I was computed using moran.test, and significance was assessed by Monte Carlo permutation tests (moran.mc, n = 999 simulations). Positive Moran’s I value with P < 0.05 indicate significant spatial clustering (aggregation), while values near 0 indicate random spatial distribution. Local Moran’s I (localmoran) was additionally calculated to identify specific hotspot regions of high–high cell type co-occurrence. All spatial analyses were performed using the spdep R package (v1.3–10). TCGA clinical data analyses We used the gene expression profiles from TCGA pan-cancer data, and only patients with available survival information were selected for further analysis. The enriched signatures of TIME subtypes, B cell subsets, and WGCNA modules were utilized to calculate module scores using the AddModuleScore R function in the TCGA dataset. We used univariate Cox regression analysis to evaluate the impact of distinct parameters on OS, and P values were obtained through the log-rank test. For a given cancer type, module scores with a hazard ratio (HR) greater than 1 and P value < 0.05 were identified as risk factors, while module scores with a HR less than 1 and P value < 0.05 were identified as protective factors. Subsequently, tumor samples from distinct cancer types were divided into high and low group based on the expression level of distinct module scores, and the Kaplan–Meier method was used to fit the survival curves between the high and low groups. Pan-cancer ICB response Geneformer construction and in silico screening The Geneformer foundational model structure was used in this study. Geneformer is composed of six transformer encoder units, each composed of a self-attention layer and feed forward neural network layer with the following parameters: input size of 4096, 256 embedding dimensions, four attention heads per layer and feed forward size of 512. Geneformer uses full dense self-attention across the input size. Depth was chosen based on the maximum depth. Further parameters were as follows: nonlinear activation function; rectified linear unit; dropout probability for all fully connected layers, 0.02; dropout ratio for attention probabilities, 0.02; standard deviation of the initializer for weight matrices, 0.02; and epsilon for layer normalization layers, 1 × 10−12. Modeling was implemented in PyTorch. The whole pan-cancer B cell atlas dataset was tokenized and pretrained. Pretraining hyperparameters were optimized to the following finial values: max learning rate, 1 × 10−3; learning scheduler linear with warmup; optimizer, Adam with weight decay fix; warmup steps, 10,000; weight decay, 0.001; and batch size, 12. After pretraining, the model was separately fine-tuned in distinct cancer types for following all genes in silico perturbation. Fine-tuning hyperparameters were optimized to the following finial values: max learning rate, 5 × 10−5; learning scheduler linear with warmup; optimizer, Adam with weight decay fix; warmup steps, 500; weight decay, 0.001; and batch size, 12. All genes were in silico perturbated to model their inhibition. The effects of the in silico perturbation are measured at the cell and gene embedding level, modeling how the perturbation affects the state of the cell and the regulation of downstream gens within the gene network. In silico deletion was modeled by removing the given gene from the value encoding of the given single-cell transcriptome and quantifying the cosine similarity between the original and perturbated cell embeddings to determine the predicted deleterious impact of deleting that gene in that cell context. Supplementary Information Below is the link to the electronic supplementary material. Supplementary file1 (DOCX 12487 KB) Supplementary file2 (CSV 1 KB) Acknowledgements None. Author contributions Conceptualization: JJW, YSC, JL Methodology: JLF, HYL, JJW Investigation: JLF, HYL Visualization: JLF, HYL Funding acquisition: JJW, YSC, JL Project administration: JLF, JL Supervision: JJW Writing—original draft: JLF Writing—review & editing: JLF, JJW, JL, YSC, HYL. Funding This work was supported by the National Natural Science Foundation of China (32301017 to J.L., 32570784 to JJ.W.), the State Key Laboratory of Metabolic Dysregulation & Prevention and Treatment of Esophageal Cancer (to YS.C.), the Construction Fund of Key Medical Disciplines of Hangzhou (2025HZGF09), and the Construction Fund of Key Medical Disciplines of Hangzhou (2025HZZD13). Data availability All relevant data can be required under reasonable requests. Declarations Conflict of interest The authors declare no competing interests. Ethical approval Not applicable. This study exclusively used publicly available, de-identified datasets (TCGA from NCI GDC Portal and single-cell RNA-seq data from NCBI GEO). No human participants were directly involved, and no clinical data were collected or analyzed in this study. Consent for publication Not applicable. Footnotes Publisher's Note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. Jialing Fang and Hangyu Liu have contributed equally to this work. Contributor Information Jun Lei, Email: leijun@whu.edu.cn. Yongshun Chen, Email: yongshun2007@163.com. Jingjing Wang, Email: jingjingw@zju.edu.cn. References Associated Data Supplementary Materials Supplementary file1 (DOCX 12487 KB) Supplementary file2 (CSV 1 KB) Data Availability Statement All relevant data can be required under reasonable requests.