8.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 10250 x 30 data matrix successfully!
## OpenMP is working. 8 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## - point 10000 of 10250
## Done in 2.88 seconds (sparsity = 0.013336)!
## Learning embedding...
## Iteration 50: error is 96.107250 (50 iterations in 2.20 seconds)
## Iteration 100: error is 84.311951 (50 iterations in 2.32 seconds)
## Iteration 150: error is 81.621430 (50 iterations in 2.23 seconds)
## Iteration 200: error is 81.006119 (50 iterations in 2.26 seconds)
## Iteration 250: error is 80.709628 (50 iterations in 2.32 seconds)
## Iteration 300: error is 3.240719 (50 iterations in 2.12 seconds)
## Iteration 350: error is 2.991369 (50 iterations in 2.05 seconds)
## Iteration 400: error is 2.856670 (50 iterations in 2.06 seconds)
## Iteration 450: error is 2.771442 (50 iterations in 2.05 seconds)
## Iteration 500: error is 2.710819 (50 iterations in 2.04 seconds)
## Iteration 550: error is 2.664889 (50 iterations in 2.02 seconds)
## Iteration 600: error is 2.628754 (50 iterations in 2.06 seconds)
## Iteration 650: error is 2.600625 (50 iterations in 2.15 seconds)
## Iteration 700: error is 2.577976 (50 iterations in 2.08 seconds)
## Iteration 750: error is 2.559499 (50 iterations in 2.07 seconds)
## Iteration 800: error is 2.544428 (50 iterations in 2.08 seconds)
## Iteration 850: error is 2.531595 (50 iterations in 2.05 seconds)
## Iteration 900: error is 2.521211 (50 iterations in 2.09 seconds)
## Iteration 950: error is 2.512387 (50 iterations in 2.08 seconds)
## Iteration 1000: error is 2.505024 (50 iterations in 2.11 seconds)
## Fitting performed in 42.44 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-965d8d97c-Date-2025-02-06_Time-01-07-22.337093.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-965d8d97c-Date-2025-02-06_Time-01-07-22.337093.log
p2 <- plotEmbedding(ArchRProj = projHeme2, colorBy = "cellColData", name = "Clusters", embedding = "TSNE")
## ArchR logging to : ArchRLogs/ArchR-plotEmbedding-97d30408f-Date-2025-02-06_Time-01-07-23.537508.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-97d30408f-Date-2025-02-06_Time-01-07-23.537508.log
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)
## Plotting Ggplot!
## Plotting Ggplot!
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-960f29936-Date-2025-02-06_Time-01-07-28.667797.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-960f29936-Date-2025-02-06_Time-01-07-28.667797.log
p2 <- plotEmbedding(ArchRProj = projHeme2, colorBy = "cellColData", name = "ScranClusters", embedding = "TSNE")
## ArchR logging to : ArchRLogs/ArchR-plotEmbedding-97aee90f5-Date-2025-02-06_Time-01-07-30.061919.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-97aee90f5-Date-2025-02-06_Time-01-07-30.061919.log
To save an editable vectorized version of this plot, we use plotPDF()
.