## 2 Materials and Methods
### Linkage Disequilibrium Score Regression (LDSC) and K-Means Clustering  
We used LDSC to estimate genetic correlations between psychiatric, cardiometabolic and sleep traits [37; 38]. The cross-trait LDSC method represents an extension of single-trait LDSC to estimate heritability and genetic correlation from GWAS summary statistics. This method allows studying the genetic correlation globally, considering the average of the shared signals across the genome (including the contribution of single nucleotide polymorphisms (SNP) that do not reach genome-wide significance [37], considering possible sample overlap and population stratification. Genetic correlation is computed by normalizing genetic covariance by SNP heritability as in Equation (1):  
\[\mathrm{r_{g}}=\frac{\mathrm{\theta_{g}}}{\sqrt{h_{1}^{2}h_{2}^{2}}} \tag{1}\]  
where \(\mathrm{\theta_{g}}\) indicates the genetic covariance and \(h_{i}^{2}\) indicates the SNP heritability from study \(i\). For case-control studies, genetic covariance is on the observed scale [37]. There is no distinction between observed and liability scale genetic correlation for case-control traits, so genetic correlation can be estimated between a case-control trait and a quantitative trait or between pairs of case-control traits, without the need to specify a scale [37]. For each study, summary statistics were converted into the LDSC format. Quality control procedures included removal of strand-ambiguous variants, duplicated variants or variants that are not SNPs. Alleles were merged with the HapMap3 SNPs, as recommended. LD scores were based on 1000 genomes European data. Results were adjusted for multiple testing using the Bonferroni correction based on the number of tests (n = 120). In order to identify clusters of genetically correlated traits, a pair-wise genetic correlation matrix including all traits was used to compute a distance matrix based on Euclidean distance, which was used as input for k-means clustering. K-means clustering is an unsupervised machine learning algorithm that aims to partition n observations into \(k\) clusters. The basic form of the k-means algorithm, in some cases also known as \"naive k-means\", uses an iterative procedure. Basically, there are two steps: the assignment and the update. The problem this algorithm tries to solve is to assign each data point to a cluster, which should be as close as possible. The number of clusters must be provided. Each cluster will be represented by a centroid, a point that represents the mean position of all points in the cluster. The procedure can be summarized in the following two steps:  
Step 1: Assignment  
In the first iteration, \(k\) points (\(\mathbf{m}_{1}\),..., \(\mathbf{m}_{k}\)) are randomly generated. These will be considered the initial centroids, one for each of the \(k\) clusters. The clusters will be defined by assigning each data point to the closest centroid, as in Equation (2). \[\mathrm{\mathbf{S}}_{i}^{(t)}=\left\{\mathbf{x_{p}}:\left|\mathbf{x_{p}}-\mathbf{m_{i}^{(t)}} \right|^{2}\leq\left|\mathbf{x_{p}}-\mathbf{m_{j}^{(t)}}\right|^{2}\forall j,1\leq j \leq k\right\} \tag{2}\]  
where each point (\(\mathbf{x_{p}}\)) is assigned to one and only one cluster (\(\mathrm{\mathbf{S}}^{(t)}\)). Step 2: UpdateIn the second step the means computed in Step 1 can be discarded since we have already formed clusters based on those means, and we can compute the new means of those clusters as in Equation (3). \[\mathbf{m}_{i}^{(t+1)}=\frac{1}{\left|S_{i}^{(t)}\right|}\sum_{\mathbf{x}_{j}\in S_{i}^{(t )}}\mathbf{x}_{j} \tag{3}\]  
Since the centroid might have changed, we need to reassign data points to a cluster. This procedure will continue until convergence; that is, until points are permanently assigned to one cluster, and new iterations would not affect this assignment. K-means clustering was conducted using the cluster package (v. 2.1.4) [39] and the factoextra package in R [40].