Ischemic stroke refers to ischemic necrosis or softening of localized brain tissue. Transcranial magnetic stimulation (TMS) is a painless, noninvasive and green treatment method, which acts on the central nervous system through a pulsed magnetic field to assist in the treatment of central nervous system injury diseases. However, the role of Il1r2 and Tnfrsf12a in this is unknown. The ischemic stroke datasets GSE81302 and TMS datasets GSE230148 were downloaded from Gene Expression Omnibus database. Differentially expressed genes (DEGs) were screened and weighted gene co-expression network analysis (WGCNA) was performed. The construction and analysis of protein-protein interaction (PPI) network and functional enrichment analysis were performed. Draw heat map gene expression. Through the Comparative Toxicogenomics Database (CTD) to find the most relevant and core gene diseases. TargetScan was used to screen miRNAs regulating DEGs. A total of 39 DEGs were identified. According to gene ontology (GO) analysis results, in biological process (BP) analysis, they were mainly enriched in the positive regulation of apoptosis process, inflammatory response, positive regulation of p38MAPK cascade, and regulation of cell cycle. In cellular component (CC) analysis, they were mainly enriched in the cell surface, cytoplasm, and extracellular space. In Kyoto Encyclopedia of Genes and Genomes (KEGG) analysis, they were mainly enriched in nf-κB signaling pathway, fluid shear stress and atherosclerosis, P53 signaling pathway, TNF signaling pathway, and apoptosis. Among the enrichment items of metascape, negative regulation of T cell activation, hematopoietic cell lineage, positive regulation of apoptotic process, fluid shear stress and atherosclerosis were observed in GO enrichment items. Five core genes (Socs3, Irf1, Il1r2, Ccr1, and Tnfrsf12a) were obtained, which were highly expressed in ischemic stroke samples. Il1r2 and Tnfrsf12a were lowly expressed in TMS samples. CTD analysis found that the core gene (Socs3, Irf1 and Il1r2, Ccr1, Tnfrsf12a) and ischemic stroke, atherosclerosis, hypertension, hyperlipidemia, thrombosis, stroke, myocardial ischemia, myocardial infarction, and inflammation. Il1r2 and Tnfrsf12a are highly expressed in ischemic stroke, but lowly expressed in TMS samples.