Background: Brain metastases (BM) are the most common malignant tumors affecting the human central nervous system, more than 50% of BM are lung cancer. However, there is currently no universal and effective screening tool for lung cancer with BM. The study aimed to identify key genes of lung cancer with BM, achieving early and accurate diagnosis of lung cancer with BM and long-term monitoring of the therapeutic response.Methods: RNA-seq data and related clinical information were downloaded from the Gene Expression Omnibus (GEO) database. The weighted gene co-expression network (WGCNA) analysis was performed using WGCNA package and MEtuequois module was considered as the highest correlation. The Limma package of R was used to obtain differentially expressed genes (DEGs) between lung cancer with BM and healthy samples. The Gene Ontology (GO) and Kyoto Encyclopedia of Genes and Genomes (KEGG) pathway enrichments of DEGs were analysed. LASSO and SVM were used to derive key genes for lung cancer with BM, and survival analysis was used to verify the correlation between the outcome and the key genes that we found. Key genes are annotated by GSEA, and CIBERSORT was used to calculate immune infiltration from samples.Results: 5 co-expression modules were detected, and ME turquois was most significantly associated with BM in lung cancer. These genes were mainly enriched in biological processes related to cell adhesion and immunity, and the main signaling pathways are significantly related to disease and cell adhesion. 4 BM-related key genes (AQP1, GSTA1, ROS1, TGFB1I1) were identified by LASSO regression analysis and SVM-RFE screening, they were demonstrated as the potential markers for lung cancer with BM. Immune cell infiltration revealed that they were negatively correlated with T cells regulatory, T cells CD8 and Mast cells activated. Overall survival correlation analysis confirmed that the expression of AQP1, GSTA1 and TGFB1I1 was negatively correlated with the prognosis of lung cancer patients, ROS1 was positively correlated with the prognosis of patients.Conclusions: AQP1, GSTA1, TGFB1I1 and ROS1 were identified as key genes of lung cancer with BM patients, which may regulate cancer progression by regulating immunity and have potential prognostic effects.