Accumulating evidence has demonstrated that tumor microenvironment (TME) plays a crucial role in stomach adenocarcinoma (STAD) development, progression, prognosis and immunotherapeutic responses. How the genes in TME interact and behave is extremely crucial for tumor investigation. In the present study, we used gene expression data of STAD available from TCGA and GEO datasets to infer tumor purity using ESTIMATE algorithms, and predicted the associations between tumor purity and clinical features and clinical outcomes. Next, we calculated the differentially expressed genes (DEGs) from the comparisons of immune and stromal scores, and postulated key biological processes and pathways that the DEGs mainly involved in. Then, we analyzed the prognostic values of DEGs in TCGA dataset, and validated the results by GEO dataset. Finally, we used CIBERSORT computational algorithm to estimate the 22 tumor infiltrating immune cells (TIICs) subsets in STAD tissues. We found that stromal and immune scores were significantly correlated with STAD subtypes, clinical stages, Helicobacter polyri infection, and stromal scores could predict the clinical outcomes in STAD patients. Moreover, we screened 307 common DEGs in TCGA and GSE51105 datasets. In the prognosis analyses, we only found OGN, JAM2, RERG, OLFML2B, and ADAMTS1 genes were significantly associated with overall survival in TCGA and GSE84437 datasets, and these genes were correlated with the fractions of T cells, B cells, macrophages, monocytes, NK cells and DC cells, respectively. Our comprehensive analyses for transcriptional data not only improved the understanding of characteristics of TME, but also provided the targets for individual therapy in STAD.