Background: Staphylococcus aureus (S. aureus) is the most common pathogen that causes osteomyelitis (OM). However, OM's pathogenesis, which is not clear, involves many factors such as environment, genetics and immunity dysregulation. This study aims to explore the key genes involved in the pathogenesis and development of OM following S. aureus infection. Methods: After obtaining the datasets of GSE6269 and GSE16129, we performed weighted gene co-expression network analysis (WGCNA) to find clusters modules of highly correlated genes and recursive feature elimination (RFE) method to narrow the range of feature genes. For determining the effect of feature genes, we constructed a random forest (RF) model with feature genes and validated the predictive validity of the RF model using independent data from GSE11908. The protein-protein interaction (PPI) network identifies essential proteins that contributed to OM development. Results: There were 12,401 genes from 77 samples that 48 S. aureus patients developed to OM and 29 of those without OM. We divided 31 significant gene modules into different modules, and the brown module significantly related to OM. Biological Functions of the brown module mainly enriched in the inflammatory response, metabolic, cancer, viral pathways, protein binding and RNA binding. After screening, 19 genes, including CYP2E1, BBS10, ARPC5L, GAPVD1, PURA, RBMS1, BTN2A2, EXOSC8, METTL8, FYCO1, KHK, PRPF38B, CD72, C2CD5, ABHD6, CD200, FAM53C, HCP5 and ELP1, were defined as feature genes for constructing RF model. After validating the external data, the average area under the curve was 85%, and the accuracy of the RF model was 85.7%. The protein function of modules enriched in the RNA exosome complex's catalytic component and regulation of actin polymerization. Conclusions: This study aimed to identify related genes involved in the occurrence and development of OM. We constructed the RF model with 19 genes, which effectively classify the patients with OM or non-OM. Despite its limitations, the study certainly adds to our understanding of OM's pathogenesis, and therefore, has significant implications for potential therapeutic targets and the predicted value of OM.