## 2 Materials and Methods
### Clustering Algorithms  
Tumor stratification from transcriptomic data aims to identify groups of samples with common characteristics (i.e., tumor subtype). This task is commonly addressed with clustering techniques. In this study, we tested four clustering algorithms, comparing their outputs: hierarchical density-based spatial clustering of applications with noise (HDBSCAN), density-based spatial clustering of applications with noise (DBSCAN), ordering points to identify the clustering structure (OPTICS), and agglomerative clustering. We chose these algorithms as they do not rely upon centroid computation which is a non trivial operation for non-Euclidean metrics.  
HDBSCAN is a density-based hierarchical method developed by [PERSON] et al. [32]. By creating a series of nested sample groups, it allows one to perform hierarchical clustering and so to explore tumor stratification on RNA-seq data in greater detail.  
The algorithm does not assign lower density points to any cluster, marking them as Noise. In this work, we referred to them as Not Clusterable (NC) points. Moreover, the algorithm requires two main hyperparameters to be defined. The first hyperparameter, Min Cluster Size (MCS), is the minimum number of elements required to build a group. The second hyperparameter, Min Samples (MS), is related to the extent of NC points. In our analysis, the MCS value was set to 30, while the MS was optimized based on the value of ARI, with testing values ranging from 1 to 100.  
The DBSCAN algorithm, proposed in 1996 [33], is the precursor of HDBSCAN. Its main hyperparameters are the maximum distance between two samples (EPS) and MS. Thefirst was optimized by testing values from 0.05 to 10, and the second one was optimized as for HDBSCAN.  
Moreover, the OPTICS algorithm [34] is closely related to DBSCAN and its main hyperparameter is MS.  
Finally, the agglomerative clustering [35] was the last one we tested. It recursively merges pairs of clusters of sample data and it requires the number of clusters to be defined; we fixed that value at 4.  
The evaluation of clustering quality and the hyperparameter optimization were based on two scores. The first score is ARI, a popular score for evaluating the quality of clustering [36; 37]. Ranging from \(-1\) to 1, it computes the similarity between the partitions generated by the algorithm and the one we expect, according to a specific clinical variable (in our analysis, the BC subtype). A value of 1 indicates that the algorithm is able, in an unsupervised manner, to aggregate the samples as defined in the clinical variable. The second score is the homogeneity [29], ranging from 0 to 1, where 1 corresponds to a perfectly homogeneous partition. A clustering result is homogeneous if all of its clusters contain only data points that are members of a single class.  
We considered it to be a good stratification result if we obtained simultaneously high scores for ARI and homogeneity. In particular, a high ARI score means that the algorithm found similar tumor subtypes to those we expected, while a high homogeneity score indicates that tumor clusters comprise samples of the same BC subtype.