AbstractThe tumor microenvironment (TME) consists of tumor-associated stroma and tumor infiltrating lymphocytes (TIL). Assessment of tumor-stroma ratio (TSR) and TIL in the histopathological specimens can provide important prognostic information in various diverse solid tumors including gastric cancer (GC). However, implementation as a routine clinical biomarker has not been developed. In 320 GC patients, a Generative Adversarial Network (GAN)-based virtual cytokeratin and leukocyte common antigen staining approach and binary image processing techniques were developed with H&E-stained slide images to computationally quantify TSR and TIL [intratumoral (tTIL) and stromal (sTIL)]. Based on TSR and TIL, a TME-based prediction model (TMEPATH) was developed from a univariable cox regression model, and a beta coefficient for each level was used to define three-class subgroups to predict survival of the GC patients. Genomic alterations associated with those TME-based prognostic models were analyzed. Based on a cut-off value of 0.76, TSR was divided into TSR_low (n = 113) and TSR_high (n = 207) types. For TIL, two TIL subtypes were developed with optimal cut-off values (0.03). As TME subtype using simple TIL (TMEPATH) showed higher discrimination performance compared to TME subtype constructed with both sTIL and tTIL, TMEPATH was finally selected. GC TMEPATH showed low risk in 91 cases (28.4%) with best survival, 167 medium risk (52.2%), and 62 high risk (19.4%) with worst survival (HR p = 0.0061, C-index 0.545, 5 year-iAUC 0.55, 5 year-tAUC 0.548). This survival difference was validated in an outside cohort (n = 182) with clinical significances (HR p = 0.0064, C-index 0.539, 5 year-iAUC 0.539, 5 year-tAUC 0.534). Moreover, TSR, TIL, and TMEPATH were significantly associated with microsatellite instability, tumor mutation burden, and mutations of CDH1. In conclusion, GC can be classified into three TME subtypes based on TSR and TIL and could predict prognosis in patients with GC.