Motivated by these results, for our second aim, we targeted CAD, to better understand the contribution of genetic risk factors for MDD and loneliness to the shared comorbidity patterns implicating CAD. Our machine learning algorithm identified 3893 cases and 4197 controls in BioVU (Supplementary Table 6). In minimally adjusted models, each SD increase in the polygenic scores for MDD and loneliness, respectively, increased the odds of CAD by 1.11 (95% CI, 1.04–1.18; P = 8.43 × 10−4) and 1.13 (95% CI, 1.08–1.20; P = 4.51 × 10−6). These findings mirrored those from the phenome-wide association study and indicated that our results were not biased by the classification ability of our algorithm. Stratified by deciles, patients with polygenic scores for MDD and loneliness in the top versus bottom deciles had, respectively, a 1.53-fold (95% CI, 1.18–1.98; P = 1.2 × 10−3) and 1.51-fold (95%CI, 1.19–1.91; P = 7.4 × 10−4) greater risk of CAD (Fig. 3). These associations persisted even after excluding patients with a clinical diagnosis of MDD, depressive symptoms, or any psychiatric symptoms (Table 1).Table 1Associations between polygenic scores