Given a dataset (A), X-shift computes the density estimate for each data point (B). It then searches for the local density maxima in a nearest-neighbor graph, which become cluster centroids. All the remaining data points are then connected to the centroids via density-ascending paths in the graph, thus forming clusters (C). The algorithm further checks for the presence of density minima on a straight line segment between the neighboring centroids and merges them as necessary (D). This is needed to ensure that the neighboring clusters, even if they have similar phenotypes, do in fact represent unique density-separated populations. Furthermore, clusters are merged based on a fixed Mahalanobis distance threshold.