Identification of differentially expressed genes in AF
To improve comparability across cohorts, two AF-related transcriptomic datasets (GSE41177 and GSE79768) were integrated, and batch effects were corrected on the merged expression matrix. Figure 2A,B shows boxplots of global expression distributions before and after batch-effect correction, which were used to evaluate whether expression intensity distributions were comparable across samples. Figure 2C,D shows principal component analysis (PCA) plots before and after batch-effect correction, which were used to evaluate sample-level clustering patterns and cohort-related separation. After correction, the global expression distributions became more consistent, and the systematic separation between cohorts was markedly attenuated in PCA space, suggesting that batch effects were effectively mitigated. Differential expression analysis was then conducted using the batch-corrected combined dataset. With FDR < 0.05 and |log2FC|>0.585 as the significance thresholds, a total of 181 DEGs were identified. The volcano plot showed a clear distribution of DEGs by effect size and statistical significance (Figure 2E). Furthermore, the top 50 DEGs ranked by significance were selected to generate a clustered heatmap, which revealed a distinct separation in expression profiles between the AF and control groups (Figure 2F), indicating that this DEG signature can effectively discriminate AF samples from normal controls.
Identification of AF-related co-expression modules by WGCNA
In the WGCNA, module-trait correlation analysis revealed that multiple modules exhibited varying degrees of association with the AF phenotype. Among them, the MEbrown module demonstrated the strongest positive correlation with AF (r = 0.437, P = 0.00034), whereas the MEgreen module exhibited the strongest negative correlation (r = -0.324, P = 0.0095) (Figure 3A), suggesting that these modules may be closely involved in AF onset and progression. To construct a robust co-expression network, soft-threshold analysis indicated that a soft-thresholding power of β = 12 best satisfied the scale-free topology criterion (Figure 3B). Using this parameter, a total of nine co-expression modules were identified (Figure 3C). The MEbrown and MEgreen modules comprised 394 genes and were carried forward for subsequent analyses.
Functional enrichment analysis of core genes and construction of the protein–protein interaction network
By intersecting DEGs, ERS-related genes, and genes from the key WGCNA module, 22 core genes were ultimately identified (Figure 4A). GO and KEGG enrichment analyses were performed for these core genes, with FDR < 0.05 considered statistically significant. GO annotation indicated that the significantly enriched terms were predominantly related to immune-associated biological processes and molecular functions, including leukocyte aggregation, antigen processing and presentation, and major histocompatibility complex (MHC)-related terms (Figure 4B,C). KEGG pathway analysis identified 30 significantly enriched pathways (Figure 4D), largely involving immune-inflammation and adaptive immune differentiation signaling, including Th1 and Th2 cell differentiation, the IL-17 signaling pathway, and the chemokine signaling pathway. Collectively, these results suggest that the core genes are closely linked to immune-inflammatory functional modules, providing clues for subsequent mechanistic investigations.
To further evaluate protein-level interactions among the core genes, a PPI network was constructed, followed by topological analysis and visualization (Figure 4E). The resulting network comprised 20 nodes (two genes were excluded because they had no recorded interactions) and exhibited high overall connectivity. Based on degree centrality, the top-ranked hub genes included TYROBP, HLA-DRA, NCF2, S100A9, S100A8, CXCL1, and RAC2, suggesting that they may represent key candidate nodes involved in AF-associated immune-inflammatory responses and ERS-related pathological processes.
Machine-learning results and validation of the core gene expression signature
Among the 113 machine-learning combinations evaluated in this study, the elastic net regression model (Enet [α = 0.2]) achieved the best overall predictive performance. The composite AUC was defined as the mean AUC across the training and independent validation cohorts (mean AUC = 0.870; training AUC = 1.000; validation cohort GSE115574 AUC = 0.740) (Figure 5A). In the independent validation cohort GSE115574, ROC analysis demonstrated that the model retained discriminatory capability (AUC = 0.740, 95% CI 0.608–0.859) (Figure 5B). In the training cohort, the model yielded an AUC of 1.000 (95% CI 1.000–1.000) (Figure 5C). Confusion matrices further illustrated differences in classification performance between the external validation and training cohorts (Figure 5D,E), indicating variability in generalizability across datasets.
Using this optimal model, 18 key feature genes were selected: AADAC, ALOX5AP, BCHE, CXCL1, CXCR4, HLA-DPB1, HLA-DQA1, IER3, MGAM, NCF2, RAC2, RPS11, S100A4, S100A8, S100A9, TYROBP, UTS2, and WT1. A nomogram based on these 18 genes was subsequently constructed to facilitate individualized risk scoring and model interpretability (Figure 5F). In single-gene discriminatory performance evaluation, ROC analysis indicated that RPS11 (AUC = 0.929) and NCF2 (AUC = 0.890) showed particularly strong discriminative power, followed by S100A4 (AUC = 0.869), MGAM (AUC = 0.855), and IER3 (AUC = 0.853) (Figure 5G). Moreover, the differential expression volcano plot suggested that these key feature genes were significantly differentially expressed between case and control groups (Figure 5H), supporting their relevance as model features at the transcriptomic level.
To further assess the external generalizability of the Enet [α = 0.2]-derived 18-gene signature, an additional validation analysis was performed in GSE14975. This dataset included 10 left atrial appendage samples, consisting of five AF samples and five sinus rhythm/control samples. All 18 signature genes were available in the GSE14975 expression matrix. Using the manuscript-consistent unsupervised ComBat harmonization strategy, the locked 18-gene signature achieved an AUC of 0.840 in GSE14975 (95% CI: 0.568–1.000) (Supplementary File 1—Supplementary Table S3 and Supplementary Figure S1). At the development-derived threshold, the sensitivity, specificity, and accuracy were all 0.800 (Supplementary File 1—Supplementary Table S3 and Supplementary Figure S2). These findings provide preliminary supportive evidence that the 18-gene signature may retain discriminatory ability in an independent AF-related transcriptomic dataset. Sample-level predicted probabilities in GSE14975 are provided in Supplementary File 1—Supplementary Table S4. At the individual gene level, several signature genes showed moderate-to-high discriminatory ability in GSE14975, including CXCL1 (AUC = 0.88), CXCR4 (AUC = 0.88), S100A8 (AUC = 0.80), HLA-DPB1 (AUC = 0.76), and IER3 (AUC = 0.76) (Supplementary File 1—Supplementary Table S5). The single-gene ROC curves for all 18 signature genes are provided in Supplementary File 1—Supplementary Figure S3 and Supplementary Figure S4. To further evaluate the stability of the signature within the development cohort, repeated internal resampling was performed. The mean AUC from repeated 10-fold cross-validation was 0.878, and bootstrap optimism correction yielded a corrected AUC of 0.945 (Supplementary File 1—Supplementary Table S6). These findings suggest that the apparent development-set performance was optimistic, but that the signature retained relatively high discriminatory ability after internal correction. Coefficient-based interpretation showed that several genes contributed more strongly to the locked signature, as indicated by the absolute magnitudes of their regression coefficients (Supplementary File 1—Supplementary Table S7 and Supplementary Figure S5). In addition, single-gene ROC analysis in GSE14975 indicated that several component genes retained moderate-to-high individual discriminative ability, supporting their contribution to the overall signature. Detailed coefficient rankings and single-gene ROC plots are provided in Supplementary File 1.
SHAP interpretability analysis
SHAP was used to quantify each feature's contribution to the model's output. The global importance ranking indicated that RPS11 contributed the most to model prediction, followed by NCF2 and S100A4, and then S100A9, IER3, ALOX5AP, S100A8, UTS2, CXCR4, CXCL1, MGAM, WT1, BCHE, HLA-DPB1, and TYROBP (Figure 6A); the remaining features showed relatively lower contributions. SHAP dependence plots further demonstrated that higher RPS11 values were generally associated with decreased SHAP values, suggesting that elevated RPS11 expression correlates with a lower predicted probability of AF. In contrast, NCF2, S100A4, S100A8/S100A9, and UTS2, among others, exhibited increasing SHAP values with higher expression levels, indicating a positive contribution to AF prediction (Figure 6B). The SHAP summary (beeswarm) plot illustrated the overall distribution of feature values and contribution directions: lower RPS11 values tended to correspond to positive SHAP values, whereas higher RPS11 values tended to correspond to negative SHAP values; conversely, NCF2 and S100A4 showed a pattern in which higher values were associated with larger positive SHAP values (Figure 6C).
At the individual level, SHAP waterfall plots for a representative case sample showed a baseline output of E[f(x)] = 0.721. Given feature contributions—most notably a relatively low RPS11 value (RPS11 = 7.71)—the model output increased to f(x) = 0.934, with RPS11 providing the largest contribution (+0.139), followed by IER3 (+0.0396) and S100A4 (+0.0335) (Figure 6D,E). Collectively, these results indicate that the model predictions are largely driven by a small subset of key genes and exhibit a consistent pattern of interpretability at both the global and individual levels.
GSEA enrichment results
To further elucidate the potential functions of the key feature genes, single-gene GSEA was performed for each of the 18 feature genes, and representative results were visualized in Figure 7. GSEA revealed that samples with high expression of NCF2, S100A8/S100A9, and other key genes were significantly enriched for immune-related pathways, including cytokine signaling and antigen presentation (p < 0.05), suggesting that these genes are markers of an activated immune microenvironment in AF (Figure 7). For instance, immune-inflammatory pathways were more prominently enriched in samples with high expression of NCF2, S100A8/S100A9, ALOX5AP, and HLA-DPB1. In contrast, the enrichment profile associated with RPS11 was more indicative of differences in fundamental biological processes, such as energy metabolism and protein synthesis (Figure 7). Overall, the GSEA results suggest that these key feature genes are closely linked to immune-inflammatory functional modules, providing functional support for interpreting AF-related molecular mechanisms from the perspectives of the immune microenvironment and inflammatory responses.
Immune infiltration analysis
Based on the immune infiltration assessment, the relative proportions of 22 immune cell types were visualized across samples (Figure 8A). Between-group comparisons revealed significant differences in the infiltration levels of several immune cell subsets between the AF and control groups: CD8 T cells were significantly reduced in the AF group (p < 0.01), activated dendritic cells were also decreased (p < 0.05), whereas neutrophils showed the most pronounced increase in the AF group (p < 0.001) (Figure 8B). Correlation analysis of immune cell fractions further elucidated interrelationships among immune subsets (Figure 8C). Notably, certain cell populations exhibited strong negative correlations; for example, resting mast cells were markedly negatively correlated with activated mast cells, suggesting that immune cell state transitions may be associated with AF-related remodeling of the immune microenvironment (Figure 8C).
In addition, correlation analyses of the 18 key feature genes with immune cell infiltration proportions revealed significant associations with multiple immune cell subsets (Figure 8D). Collectively, these findings support the presence of an altered immune-inflammatory microenvironment in AF, from both the immune cell composition and gene-immune cell association perspectives, and provide clues for subsequent mechanistic studies.
Single-cell localization of key genes and stratified analysis in monocyte-macrophages
First, cell types were annotated based on the expression patterns of canonical marker genes for each population, which exhibited clear and cell-type-specific marker expression profiles (Figure 9A). The clustering results were subsequently visualized in UMAP space, and the major cell populations identified included NK cells, vascular smooth muscle cells, T cells, endothelial cells, monocyte-macrophages, B cells, inflammatory activated myeloid cells, and fibroblasts (Figure 9B). A heatmap of marker gene expression further highlighted transcriptomic differences across cell types, providing additional support for the above annotations (Figure 9C). On this basis, the single-cell expression distributions of the 18 key feature genes were visualized, revealing pronounced cell-type-biased expression patterns across different cell populations (Figure 9D). The composite score of the 18-gene signature (integrating AUCell, ssGSEA, and AddModuleScore) was next compared across cell types; consistent results across scoring methods indicated that this signature was generally elevated in monocyte-macrophages (Figure 9E). Accordingly, monocyte-macrophages were stratified into high- and low-score subgroups based on the signature score, and their gene expression characteristics were visualized (Figure 9F). Pseudotime trajectory analysis showed differential distribution patterns of the high- versus low-score subgroups across distinct stages of the trajectory, suggesting that the signature may be associated with monocyte-macrophage state transitions (Figure 9G). In addition, cell-cell interaction network analysis revealed extensive connectivity between the high- and low-score subgroups and other cell types, with denser links to immune-related populations, suggesting that intercellular communication within the immune microenvironment may contribute to the functional phenotypes associated with this signature (Figure 9H–K).
Collectively, the single-cell results suggest that the ERS-related signature is preferentially enriched in the monocyte-macrophage lineage and may be associated with monocyte-macrophage state transitions and altered intercellular communication patterns. These findings should be interpreted as association-based transcriptomic evidence rather than proof of a causal mechanism. The immune changes inferred from bulk transcriptomic deconvolution were further compared with those observed in the single-cell analysis. In the bulk analysis, neutrophils were increased in AF samples, whereas CD8 T cells and activated dendritic cells were decreased. In the single-cell analysis, the ERS-related signature was preferentially enriched in monocyte-macrophage cells, and inflammatory activated myeloid cells were identified as an additional myeloid population. These results are partially consistent in supporting myeloid-lineage involvement in AF-related immune remodeling. However, the dominant immune populations differed between the two analytical strategies, with bulk deconvolution emphasizing neutrophil changes and single-cell analysis highlighting monocyte-macrophage-associated ERS signature enrichment.
DATA AVAILABILITY
No new raw sequencing data were generated in this study. All raw and processed transcriptomic datasets analyzed in this protocol are publicly available from the Gene Expression Omnibus (GEO) database under accession numbers GSE41177, GSE79768, GSE115574, GSE14975, and GSE165838. All analysis scripts, example input files, and parameter settings are available at the GitHub repository: https://github.com/tengfeitcm/Endoplasmic-Reticulum.git.

Figure 1. Flowchart of the data collection and analysis process. The flowchart outlines the major analytical stages from data retrieval to single‑cell mapping, including batch correction, differential expression analysis, WGCNA, ERS‑related gene selection, machine‑learning model building and validation, SHAP interpretation, immune infiltration analysis, and single‑cell characterization. Abbreviations: ERS = endoplasmic reticulum stress; SHAP = SHapley Additive exPlanations; WGCNA = weighted gene co-expression network analysis. Please click here to view a larger version of this figure.

Figure 2. Batch correction and differential expression analysis of merged bulk cohorts. (A) Boxplots showing global expression distributions across samples before batch-effect correction. (B) Boxplots showing global expression distributions across samples after batch-effect correction. These panels evaluate the comparability of expression intensity distributions. (C) PCA plot before batch-effect correction showing sample-level clustering and cohort-related separation. (D) PCA plot after batch-effect correction showing reduced cohort-related separation. These panels evaluate the effect of batch correction on global sample clustering. (E) Volcano plot of DEGs between AF and controls. (F) Heatmap of DEGs across samples in the merged cohort. Abbreviations: AF = atrial fibrillation; DEGs = differentially expressed genes; PCA = principal component analysis. Please click here to view a larger version of this figure.

Figure 3. AF-associated co-expression modules identified by WGCNA. (A) Module-trait correlation heatmap. (B) Soft-threshold power selection for scale-free topology. (C) Gene clustering dendrogram with module assignment. Abbreviations: AF = atrial fibrillation; WGCNA = weighted gene co-expression network analysis. Please click here to view a larger version of this figure.

Figure 4. Screening and functional annotation of ERS-related core genes. (A) Venn diagram showing the intersection of DEGs, WGCNA module genes, and ERS-related genes. (B) GO enrichment bar plot of the 22 genes. (C) GO enrichment circle plot of the 22 genes. (D) KEGG pathway enrichment dot plot of the 22 genes. (E) PPI network constructed from the 22-gene set; 20 connected nodes are shown because two genes had no recorded interactions, with hub nodes highlighted. Abbreviations: DEGs = differentially expressed genes; ERS = endoplasmic reticulum stress; GO = Gene Ontology; KEGG = Kyoto Encyclopedia of Genes and Genomes; PPI = protein-protein interaction; WGCNA = weighted gene co-expression network analysis. Please click here to view a larger version of this figure.

Figure 5. Machine-learning model selection and performance of the 18-gene Enet signature. (A) Heatmap of AUCs across 113 machine-learning model combinations. (B) ROC curve of the Enet model in the external validation cohort. (C) ROC curve of the Enet model in the training cohort. (D) Confusion matrix of the Enet model in the external validation cohort. (E) Confusion matrix of the Enet model in the training cohort. (F) Nomogram based on the 18-gene Enet signature. (G) ROC curves for individual signature genes in the training cohort. (H) Volcano plot highlighting the 18 signature genes. Abbreviations: AUC = area under the curve; Enet = elastic net; ROC = receiver operating characteristic. Please click here to view a larger version of this figure.

Figure 6. SHAP analysis. (A) Global feature importance ranked by mean absolute SHAP values. (B) SHAP dependence plots showing the effect of individual signature genes. (C) SHAP summary beeswarm plot illustrating feature contributions across samples. (D) SHAP waterfall plot for a representative sample. (E) SHAP force plot for a representative sample. Abbreviations: SHAP = SHapley Additive exPlanations. Please click here to view a larger version of this figure.

Figure 7. GSEA of pathways associated with signature genes. GSEA enrichment plots comparing high- vs low-expression groups for representative signature genes. Abbreviations: GSEA = gene set enrichment analysis. Please click here to view a larger version of this figure.

Figure 8. Immune infiltration profiling and association with signature genes. (A) Stacked bar plot of inferred immune-cell fractions per sample. (B) Boxplots comparing immune-cell fractions between groups. (C) Correlation heatmap among immune-cell fractions. (D) Correlation network linking immune-cell fractions and signature gene expression. For all panels, *p < 0.05, **p < 0.01, ***p < 0.001 unless otherwise specified. Please click here to view a larger version of this figure.

Figure 9. Single-cell mapping of the ERS-related signature and monocyte-macrophage-centered analyses. (A) Dot plot of canonical marker genes used for cell-type annotation. (B) UMAP visualization of major cell populations. (C) Heatmap of marker gene expression across annotated cell types. (D) Feature plots showing single-cell expression distributions of the 18 signature genes. (E) Comparison of 18-gene signature composite scores across cell types using AUCell, ssGSEA, and AddModuleScore. (F) Monocyte-macrophages stratified into high- and low-score subgroups with corresponding gene expression patterns. (G) Pseudotime trajectory analysis showing the distribution of high- and low-score subgroups along state transitions. (H) Cell-cell communication network depicting interactions between high/low-score monocyte-macrophages and other cell types. (I) Outgoing and incoming signaling-pattern heatmaps from the cell-cell communication analysis. (J–K) Bubble plots showing selected ligand-receptor interaction patterns among annotated cell populations. Abbreviations: AUCell = area under the curve-based single-cell gene-set scoring; ERS = endoplasmic reticulum stress; ssGSEA = single-sample gene set enrichment analysis; UMAP = Uniform Manifold Approximation and Projection. Please click here to view a larger version of this figure.
Supplementary File 1. Supplementary figures and tables. This file contains five Supplementary Figures and seven Supplementary Tables, including the additional GSE14975 external validation outputs, predicted probabilities, single-gene AUC/ROC results, internal resampling and bootstrap optimism-correction results, coefficient rankings for the Enet [α = 0.2]-derived 18-gene signature, public dataset characteristics, and the reproducibility checkpoint table. Abbreviations: AUC = area under the curve; Enet = elastic net; ROC = receiver operating characteristic.Please click here to download this file.