Question: I've gotten some conflicting opinions on this question from several different researchers I work with. For context, this question is with respect to single cell RNAseq data specifically. Some say to run clustering on the principal components, others say to run clustering on the t-SNE components (which were themselves run on top of the PCA components). [This post on Cross Validated][1] says that since t-SNE doesn't preserve density / distance relationships between points, running clustering on the t-SNE components isn't correct. This was corroborated by a colleague who described t-SNE (and UMAP) as "just visualization techniques"; I don't know if that's a correct definition of those processes though. However, another colleague prefers to run clustering on the t-SNE components, and empirically I seem to get better results *visually* when I cluster that way. Is there a definitive answer to this question / what is considered "best practices" in your work?

[1]: https://stats.stackexchange.com/questions/263539/clustering-on-the-output-of-t-sne

Answer: As you point out, and contrary to what many people believe, PCA and t-SNE are dimensionality reduction rather than clustering techniques. The fact that often we can "see" clusters in 2D or 3D representations by PCA and t-SNE means that there is internal structure in data, but it doesn't automatically lead to clustering. In that sense, both are primarily used for visualizations.

If your intent is to rigorously cluster data, especially based on distances, it should be done either on original data, or on data where non-informative features have been eliminated. Sometimes it helps to discretize the data before clustering, for example by using minimum description length binning. The latter technique also has the effect of removing non-informative features. We have to always keep in mind that dimensionality reduction removes both information and noise from the original dataset.

All that said, people cluster both on PCA and t-SNE embeddings of data quite effectively. Since PCA is a linear transformation, one can use distance-based clustering afterward, but as already pointed out you may need more than first 2 components (and sometimes many components) to include all meaningful data variance. t-SNE is non-linear and therefore doesn't preserve distances, but in my experience it does preserve the density in most cases when the perplexity parameter is chosen at least somewhat correctly. In the example you gave above, and with which I disagree, the argument is that a simple 2-cluster dataset can't be resolved when one chooses a perplexity of 20 or 40. Roughly speaking, perplexity is the minimal number of neighbors each data point is expected to have. For a dataset of 1000 total points as in that example you cited, the upper number of clusters for t-SNE to consider is roughly set at 50 (p=20), 25 (p=40) and 13 (p=80). The closer we are in our guess to the actual number of clusters (2), the more "clusterable" our embedding will be. Obviously, 50 potential clusters with p=20 is quite a bit off from the actual 2, and 13 potential clusters with p=80 is much closer. The visual would be even better (and easier to cluster) with p=100, but the original poster did not attempt that. To me, choosing a correct perplexity is similar to choosing K in K-means clustering: if your choice is far off from the actual number, you may end up with wrong clusters. We would get a wrong K-means clustering solution in the example you referenced above if we chose K=10.

From a practical point of view, if you ever decide to cluster based on t-SNE embeddings, it should be density-based rather than distance-based. As to whether it works, it has been shown many times by many people to work, though one needs to exercise caution. Having data with little or no noise helps as well. I will demonstrate this on clustering that was done on t-SNE embedding from tetranucleotide frequencies (# features = 256) of a metagenomic dataset - this means mixed DNA from many species where we don't know the exact origin. This is how the clusters look like.

![enter image description here][1]

To independently test whether this clustering is reliable, we have spiked in DNAs from 3 known species, and this is where they fall in that plot.

![enter image description here][2]

Hopefully it is clear that all 3 known genomes are resolved well within the existing structure. That doesn't mean that all clusters have been assigned with 100% accuracy, but we know from other experiments that many of them are.

In short: there is stronger mathematical justification to cluster from PCA embedding than from t-SNE, especially if one can find reliably the number of PCs to use (this is not automatic). Still, one can get just as good or better clustering with t-SNE embedding if we can find good approximation for perplexity (this is not automatic either).

[1]: https://i.ibb.co/rb63Pzt/Kcrypto-WS-Washburn-ALL-bh-t-SNE-contigs-20k-5k-4mer-2-D-perp20.png
[2]: https://i.ibb.co/HDNDNWb/MD-contigs-20k-5k-4mer-2-D-perp20.png