Background: Dilated cardiomyopathy (DCM) is a common cause of heart failure. In this study, we screened the immune infiltration-related genes associated with DCM to explore the potential molecular mechanisms and provide a basis for the early diagnosis and development of new immunotherapeutic targets.Methods: A dataset related to DCM was downloaded from the GEO database. R software was applied to the genetic differential analysis of DCM patients and healthy individuals, and the obtained differential expressed genes (DEGs) were screened for differentially expressed immune-related genes (DEIRGs) after comparison with the immune microsatellite database. Gene functional analysis was performed to establish a protein interaction network (PPI). The CIBERSORT algorithm was used to assess immune infiltration in patients with DCM versus normal controls, the hub genes were screened by the MOCDE app, and the hubs were validated in multiple datasets.Results: A total of 246 DEGs were screened (adj. P < 0.05 and |logFC| > 0.3), and a total of 170 DEIRGs were compared. Gene Ontology analysis showed significant (adj. P < 0.05) Biological Process entries of 591, Cellular Component of 10 and Molecular Function of 39; Kyoto Encyclopedia of Genes and Genomes showed a total of 20 significant entries, mainly focused on cytokines involved in immune response related, etc. A protein interaction network consisting of 28 hub DEGs was constructed in combination with the PPI network interactions. DEIRG was mainly distributed in the T cell receptor pathway by immune infiltration detection analysis, and significant changes in central memory T cells were found by analysis of T cell-related subpathways, where INSR, HLA-B, IFITM1 and HBEGF were significantly differentially expressed. Finally, HLA-B was found to be significantly differentially expressed by multiple microarray verification.Conclusions: HLA-B is closely related to the pathogenesis of DCM, and its altered expression may be associated with the immune response involving T cells, which ultimately leads to DCM. The detailed mechanism needs to be further explored.