BackgroundThe immune system significantly participates in the pathologic process of atrial fibrillation (AF). However, the molecular mechanisms underlying this participation are not completely explained. The current research aimed to identify critical genes and immune cells that participate in the pathologic process of AF.MethodsCIBERSORT was utilized to reveal the immune cell infiltration pattern in AF patients. Meanwhile, weighted gene coexpression network analysis (WGCNA) was utilized to identify meaningful modules that were significantly correlated with AF. The characteristic genes correlated with AF were identified by the least absolute shrinkage and selection operator (LASSO) logistic regression and support vector machine recursive feature elimination (SVM-RFE) algorithm.ResultsIn comparison to sinus rhythm (SR) individuals, we observed that fewer activated mast cells and regulatory T cells (Tregs), as well as more gamma delta T cells, resting mast cells, and M2 macrophages, were infiltrated in AF patients. Three significant modules (pink, red, and magenta) were identified to be significantly associated with AF. Gene enrichment analysis showed that all 717 genes were associated with immunity- or inflammation-related pathways and biological processes. Four hub genes (GALNT16, HTR2B, BEX2, and RAB8A) were revealed to be significantly correlated with AF by the SVM-RFE algorithm and LASSO logistic regression. qRT–PCR results suggested that compared to the SR subjects, AF patients exhibited significantly reduced BEX2 and GALNT16 expression, as well as dramatically elevated HTR2B expression. The AUC measurement showed that the diagnostic efficiency of BEX2, HTR2B, and GALNT16 in the training set was 0.836, 0.883, and 0.893, respectively, and 0.858, 0.861, and 0.915, respectively, in the validation set.ConclusionsThree novel genes, BEX2, HTR2B, and GALNT16, were identified by WGCNA combined with machine learning, which provides potential new therapeutic targets for the early diagnosis and prevention of AF.