## 2 Materials and Methods
### Reproducibility  
Due to use of stochasticity for optimization, the UMAP reproducibility is not exact ([[https://umap-learn.readthedocs.io/en/latest/reproducibility.html](https://umap-learn.readthedocs.io/en/latest/reproducibility.html)]([https://umap-learn.readthedocs.io/en/latest/reproducibility.html](https://umap-learn.readthedocs.io/en/latest/reproducibility.html)), accessed on 20 April 2022). This means that, for some datasets such as RNA-seq data, where the tumor subgroups are a complex function of the transcriptomic profiles, applying a clustering algorithm on two different runs of UMAP might return two different outputs. We showed that, although relatively stable, the results have a minimum of variability in terms of the number of estimated clusters, or samples belonging to the same or different group. When it is important to identify the correct number of clusters, as in tumor stratification, it is crucial to rely on algorithms that reproduce the same output over several runs, in order to have reliable results. Therefore, for each NN, to obtain a robust clustering result and to quantify how frequently a sample was paired to another sample set, we propose a new pipeline of analysis that applies a clustering algorithm to \(T\) different UMAP embeddings, where \(T\) is the number of runs, and compacts all the HDBSCAN tumor groups into one final reproducible output. Specifically, we defined the binary proximity matrix \(A_{t}\), which indicates if two samples belong to the same cluster. Then, after \(T\) iterations, we computed the affinity matrix \(P\) as:  
\[P=\frac{1}{T}\sum_{t=1}^{T}A_{t}.\]  
The square matrix \(P\) quantifies how frequently a pair of samples was clustered together, ranging from 0 (never) to 1 (always). Hence, from \(P\) we know the strength with which two individuals belong to the same group, but to obtain a final stratification we must apply a clustering algorithm to \(P\). Spectral clustering (SC) is the most straightforward way to perform clustering, starting from the affinity matrix [38; 39; 40]. However, the SC algorithm requires the number of clusters \(k\) to be returned as a hyperparameter. We set \(k\) equal to the mode of the number of partitions observed during the \(T\) runs, since it is the favorite solution proposed over the \(T\) runs. In the Supplementary Material, we demonstrate via simulations how our method yields a more reproducible clustering output than the implementation of a clustering algorithm on a single UMAP run. Nevertheless, result reproducibility came at the cost of losing latent space visualization, since the final clusters were no longer computed on one specific embedding, but rather were estimated from several embeddings. However, to visualize the UMAP data projection in a way that best represents the final clustering labels, from \(T\) embeddings we selected the one with the most similar clustering result in terms of ARI. This is just a visual approximation, merely useful for results presentation; nevertheless, we were interested here in the reproducibility of the tumor stratification results, that is, in having tumor subgroups that are well-identifiable even if the entire analysis is run many times. Finally, once we had reproducible cluster outputs coming from different geometrical representations, we chose the one with the highest ARI. Our methodological workflow is depicted in Figure 1.  
Hyperparameters of the pipeline (Algorithm 1) are: the output metric \(M\), the NN, the number of runs \(T\), and the clustering algorithm.