6.2 t-Stocastic Neighbor Embedding (t-SNE)

To run t-SNE in ArchR we use the addTSNE() function:

projHeme2 <- addTSNE(
    ArchRProj = projHeme2, 
    reducedDims = "IterativeLSI", 
    name = "TSNE", 
    perplexity = 30
)

## Read the 10251 x 30 data matrix successfully!
## OpenMP is working. 9 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities…
## Building tree…
## - point 10000 of 10251
## - point 10000 of 10251
## Done in 9.33 seconds (sparsity = 0.013318)!
## Learning embedding…
## Iteration 50: error is 96.116599 (50 iterations in 7.59 seconds)
## Iteration 100: error is 84.202047 (50 iterations in 7.93 seconds)
## Iteration 150: error is 81.634548 (50 iterations in 6.24 seconds)
## Iteration 200: error is 80.924221 (50 iterations in 6.33 seconds)
## Iteration 250: error is 80.681514 (50 iterations in 6.60 seconds)
## Iteration 300: error is 3.272456 (50 iterations in 5.98 seconds)
## Iteration 350: error is 3.003011 (50 iterations in 5.69 seconds)
## Iteration 400: error is 2.860067 (50 iterations in 5.58 seconds)
## Iteration 450: error is 2.771029 (50 iterations in 5.53 seconds)
## Iteration 500: error is 2.708926 (50 iterations in 5.58 seconds)
## Iteration 550: error is 2.662250 (50 iterations in 5.49 seconds)
## Iteration 600: error is 2.626274 (50 iterations in 5.53 seconds)
## Iteration 650: error is 2.597377 (50 iterations in 5.48 seconds)
## Iteration 700: error is 2.573140 (50 iterations in 5.48 seconds)
## Iteration 750: error is 2.553895 (50 iterations in 5.43 seconds)
## Iteration 800: error is 2.540270 (50 iterations in 5.46 seconds)
## Iteration 850: error is 2.531147 (50 iterations in 5.64 seconds)
## Iteration 900: error is 2.524095 (50 iterations in 5.73 seconds)
## Iteration 950: error is 2.517901 (50 iterations in 5.63 seconds)
## Iteration 1000: error is 2.511794 (50 iterations in 5.47 seconds)
## Fitting performed in 118.39 seconds.

Similar to UMAP, we can plot the t-SNE embedding using plotEmbedding(). The same parameters apply to colorBy and name regardless of which type of embedding is being used.

p1 <- plotEmbedding(ArchRProj = projHeme2, colorBy = "cellColData", name = "Sample", embedding = "TSNE")

## ArchR logging to : ArchRLogs/ArchR-plotEmbedding-efee11770af1-Date-2020-04-15_Time-09-52-22.log
## If there is an issue, please report to github with logFile!
## Getting UMAP Embedding
## ColorBy = cellColData
## Plotting Embedding
## 1
## ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-efee11770af1-Date-2020-04-15_Time-09-52-22.log

p2 <- plotEmbedding(ArchRProj = projHeme2, colorBy = "cellColData", name = "Clusters", embedding = "TSNE")

## ArchR logging to : ArchRLogs/ArchR-plotEmbedding-efee339a10ad-Date-2020-04-15_Time-09-52-23.log
## If there is an issue, please report to github with logFile!
## Getting UMAP Embedding
## ColorBy = cellColData
## Plotting Embedding
## 1
## ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-efee339a10ad-Date-2020-04-15_Time-09-52-23.log

ggAlignPlots(p1, p2, type = "h")

To save an editable vectorized version of this plot, we use plotPDF().

plotPDF(p1,p2, name = "Plot-TSNE-Sample-Clusters.pdf", ArchRProj = projHeme2, addDOC = FALSE, width = 5, height = 5)

## [1] “plotting ggplot!”
## [1] “plotting ggplot!”
## [1] 0

Download PDF : Plot-TSNE-Sample-Clusters.pdf

As we did with UMAP, we can compare the clustering results from Seurat::FindClusters() with the results of clusering with scran:

p1 <- plotEmbedding(ArchRProj = projHeme2, colorBy = "cellColData", name = "Sample", embedding = "TSNE")

## ArchR logging to : ArchRLogs/ArchR-plotEmbedding-efeeb55d566-Date-2020-04-15_Time-09-52-45.log
## If there is an issue, please report to github with logFile!
## Getting UMAP Embedding
## ColorBy = cellColData
## Plotting Embedding
## 1
## ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-efeeb55d566-Date-2020-04-15_Time-09-52-45.log

p2 <- plotEmbedding(ArchRProj = projHeme2, colorBy = "cellColData", name = "ScranClusters", embedding = "TSNE")

## ArchR logging to : ArchRLogs/ArchR-plotEmbedding-efee4843c8ed-Date-2020-04-15_Time-09-52-46.log
## If there is an issue, please report to github with logFile!
## Getting UMAP Embedding
## ColorBy = cellColData
## Plotting Embedding
## 1
## ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-efee4843c8ed-Date-2020-04-15_Time-09-52-46.log

ggAlignPlots(p1, p2, type = "h")

To save an editable vectorized version of this plot, we use plotPDF().

plotPDF(p1,p2, name = "Plot-tSNE-Sample-ScranClusters.pdf", ArchRProj = projHeme2, addDOC = FALSE, width = 5, height = 5)

## [1] “plotting ggplot!”
## [1] “plotting ggplot!”
## [1] 0

Download PDF : Plot-tSNE-Sample-ScranClusters.pdf