## 2 Materials and Methods
### Local Genetic Correlation Analysis  
Based on the previously described analyses suggesting a bidirectional association between MDD and insomnia, we further investigated the association between these two traits using local genetic correlation analysis, with Local Analysis of [co] Variant Association (LAVA) [52]. In addition, we investigated whether the cardiometabolic and inflammatory phenotypes (BMI, T2D, CRP and CAD) might moderate the association between MDD and insomnia at the identified loci.  
MR analyses with MDD as the exposure and insomnia as the outcome conducted using single SNP tests as described in the previous section showed a significant causal effect of MDD on insomnia for 10 SNPs among the 39 selected as IVs. Similarly, MR analyses with insomnia as the exposure and MDD as the outcome conducted using single SNP tests were significant for 8 SNPs among the 12 selected as IVs. These 10 + 8 SNPs were locatedin 15 genetic loci based on the genome partition file developed by the authors of LAVA [52]. These 15 loci were used as input for the local genetic correlation analysis made with LAVA. The 1000 Genomes phase 3 European data were used as reference. For each locus, we converted the marginal SNP effects within the locus to their corresponding joint effects (in order to account for the linkage disequilibrium between SNPs). To give a brief overview, for any locus and for each quantitative phenotype \(p\), we assume a linear model  
\[Y_{p}=X\alpha_{p}+\epsilon_{p} \tag{4}\]  
where \(Y_{p}\) is the standardized phenotype vector, \(X\) the standardized genotype matrix, \(\alpha_{p}\) the vector of standardized joint SNP effects and \(\epsilon_{p}\) the vector of normally distributed residuals with mean of 0 and variance \(\eta_{p}^{2}\). We denote the SNP LD matrix as S = cor(X) and the vector of estimated marginal SNP effects \(\overset{\wedge}{\beta}_{p}\), and obtain the estimated joint effects as \(\overset{\wedge}{\alpha}_{p}=\text{S}^{-1}\overset{\wedge}{\beta}_{p}\), using the genotype reference to compute \(S\). A more detailed explanation, as well as the procedure to obtain the joint SNP effects for binary phenotypes, are reported in the LAVA reference article [52].  
For each locus, the genetic covariance matrix \(\Omega\) was computed as in Equation (5).  
\[\Omega=\frac{t(\delta)^{\prime}\delta}{K-\sigma^{2}} \tag{5}\]  
where \(K\) represents the number of SNPs/principal components (PC) within the locus, \(\delta\) the estimated PC projected joint SNP effects and \(\sigma^{2}\) the sampling covariance.  
To correct for sample overlap, we computed a sampling correlation matrix (i.e., a matrix reporting the phenotypic correlation that is due to sample overlap) using the intercept from cross-trait LDSC [38]. We used the univariate test implemented in LAVA to test the local heritability within each locus for MDD and insomnia, in order to determine the amount of local genetic signal for both phenotypes and filter out non-associated loci. Local heritability can be defined as the proportion of the variance of a trait that can be explained by the SNPs in that locus. Computation of local heritability has been detailed in [52]. For these analyses, \(p\)-values were adjusted according to Bonferroni based on 60 univariate tests (i.e., 15 loci \(\times\) 6 investigated phenotypes). For loci for which we identified a significant heritability for both MDD and insomnia based on the univariate test, we computed the bivariate local genetic correlation between the two traits, resulting in 30 bivariate tests. For bivariate local genetic correlations, \(p\)-values were adjusted based on the 30 conducted tests. In case of significant bivariate local genetic correlations between either MDD or insomnia and a cardiometabolic trait, and in order to assess whether the latter explained the observed association between MDD and insomnia, a partial correlation analysis conditioned on the cardiometabolic trait(s) was also conducted.