t-SNE
Purpose
t-SNE is a nonlinear dimensionality reduction method used to visualize cells in two dimensions.
In Seurat, t-SNE is usually run with RunTSNE().
t-SNE is a visualization method. It does not create clusters by itself. Cluster labels usually come from FindClusters().
Where It Fits
Typical position:
RunPCA() -> FindNeighbors() -> FindClusters() -> RunTSNE()
After Harmony integration:
RunPCA() -> RunHarmony() -> FindNeighbors() -> FindClusters() -> RunTSNE()
Run t-SNE after choosing the reduction and dimensions used for downstream analysis.
Choose Reduction And Dims
Use the same reduction and dimensions used for graph construction.
Common choices:
| Workflow | reduction |
dims |
|---|---|---|
| Classic PCA | "pca" |
selected PCs, often 1:30 |
| SCT PCA | "pca" |
selected PCs, often 1:40 |
| CCA/SCT integration | "pca" |
PCs computed from integrated assay |
| Harmony integration | "harmony" |
selected Harmony dimensions |
Run t-SNE
For classic, SCT, or integrated assay PCA:
dims <- 1:30
seu <- Seurat::RunTSNE(
object = seu,
reduction = "pca",
dims = dims,
dim.embed = 2,
seed.use = 42,
verbose = TRUE
)For Harmony:
dims <- 1:30
seu <- Seurat::RunTSNE(
object = seu,
reduction = "harmony",
dims = dims,
dim.embed = 2,
seed.use = 42,
verbose = TRUE
)RunTSNE() stores the result as a reduction, usually named tsne.
dim.embed = 2 sets the output embedding dimension. The default 2D t-SNE layout is usually used for visualization.
Check t-SNE
Check reductions:
Seurat::Reductions(seu)Extract t-SNE coordinates:
tsne_embeddings <- Seurat::Embeddings(
object = seu,
reduction = "tsne"
)
head(tsne_embeddings)Plot t-SNE
Plot clusters on t-SNE:
Seurat::DimPlot(
object = seu,
reduction = "tsne",
group.by = "seurat_clusters",
label = TRUE, # show cluster labels
repel = TRUE # avoid label overlap
)Plot metadata on t-SNE:
Seurat::DimPlot(
object = seu,
reduction = "tsne",
group.by = "sample"
)Plot gene expression on t-SNE:
Seurat::FeaturePlot(
object = seu,
features = "MS4A1",
reduction = "tsne"
)Note
t-SNE is useful for visualization, but distances between far-apart groups should not be overinterpreted.
Changing reduction, dims, or seed.use can change the t-SNE layout.