BackgroundGastric cancer (GC) is the fifth most common cancer and the second leading cause of cancer-related deaths worldwide. Due to the lack of specific markers, the early diagnosis of gastric cancer is very low, and most patients with gastric cancer are diagnosed at advanced stages. The aim of this study was to identify key biomarkers of GC and to elucidate GC-associated immune cell infiltration and related pathways.MethodsGene microarray data associated with GC were downloaded from the Gene Expression Omnibus (GEO). Differentially expressed genes (DEGs) were analyzed using Gene Ontology (GO), Kyoto Gene and Genome Encyclopedia, Gene Set Enrichment Analysis (GSEA) and Protein−Protein Interaction (PPI) networks. Weighted gene coexpression network analysis (WGCNA) and the least absolute shrinkage and selection operator (LASSO) algorithm were used to identify pivotal genes for GC and to assess the diagnostic accuracy of GC hub markers using the subjects’ working characteristic curves. In addition, the infiltration levels of 28 immune cells in GC and their interrelationship with hub markers were analyzed using ssGSEA. And further validated by RT-qPCR.ResultsA total of 133 DEGs were identified. The biological functions and signaling pathways closely associated with GC were inflammatory and immune processes. Nine expression modules were obtained by WGCNA, with the pink module having the highest correlation with GC; 13 crossover genes were obtained by combining DEGs. Subsequently, the LASSO algorithm and validation set verification analysis were used to finally identify three hub genes as potential biomarkers of GC. In the immune cell infiltration analysis, infiltration of activated CD4 T cell, macrophages, regulatory T cells and plasmacytoid dendritic cells was more significant in GC. The validation part demonstrated that three hub genes were expressed at lower levels in the gastric cancer cells.ConclusionThe use of WGCNA combined with the LASSO algorithm to identify hub biomarkers closely related to GC can help to elucidate the molecular mechanism of GC development and is important for finding new immunotherapeutic targets and disease prevention.