We’ll demonstrate visualization techniques in Seurat using our previously computed Seurat object from the 2,700 PBMC tutorial. You can download that here

library(Seurat)
pbmc <- readRDS(file = "~/Downloads/seurat_resources/pbmc3k_final.rds")
pbmc
## An object of class seurat in project 10X_PBMC 
##  13714 genes across 2638 samples.

Five visualizations of marker gene expression

features.plot <- c("LYZ", "CCL5", "IL32", "PTPRCAP", "FCGR3A", "PF4")
# Ridge plots - from ggridges. Visualize single cell expression
# distributions in each cluster
RidgePlot(object = pbmc, features.plot = features.plot, nCol = 2)

# Violin plots. Visualize single cell expression distributions in each
# cluster
VlnPlot(object = pbmc, features.plot = features.plot, x.lab.rot = TRUE)

# Dot plots - the size of the dot corresponds to the percentage of cells
# expressing the gene in each cluster. The color represents the average
# expression level
DotPlot(object = pbmc, genes.plot = features.plot, plot.legend = TRUE)

# Feature plot - visualize gene expression in low-dimensional space
FeaturePlot(object = pbmc, features.plot = features.plot, cols.use = c("lightgrey", 
    "blue"))

# Single cell heatmap of gene expression
DoHeatmap(object = SubsetData(object = pbmc, max.cells.per.ident = 100), genes.use = features.plot, 
    slim.col.label = TRUE, group.label.rot = TRUE)

New additions to FeaturePlot

# Plot a legend to map colors to expression levels
FeaturePlot(object = pbmc, features.plot = "MS4A1", no.legend = FALSE)

# Adjust the contrast in the plot
FeaturePlot(object = pbmc, features.plot = "MS4A1", no.legend = FALSE, min.cutoff = 1, 
    max.cutoff = 3)

# Calculate gene-specific contrast levels based on quantiles of non-zero
# expression. Particularly useful when plotting multiple markers
FeaturePlot(object = pbmc, features.plot = c("MS4A1", "PTPRCAP"), no.legend = FALSE, 
    min.cutoff = "q10", max.cutoff = "q90")

# Visualize co-expression of two genes simultaneously. in beta mode (data is
# currently discretized, will be placed on a continuous scale soon)
FeaturePlot(object = pbmc, features.plot = c("MS4A1", "CD79A"), cols.use = c("grey", 
    "red", "blue", "green"), overlay = TRUE, no.legend = FALSE)

# Inspire fear and awe at your next lab meeting.
FeaturePlot(object = pbmc, features.plot = c("MS4A1", "PTPRCAP"), no.legend = FALSE, 
    min.cutoff = "q10", max.cutoff = "q90", dark.theme = TRUE)

# Dark themes are also available with the `DarkTheme` function, and can be
# added to any ggplot2-based plot.

Interactive plotting features

Seurat utilizes R’s plotly graphing library to create interactive plots. Just pass do.hover = TRUE to FeaturePlot, CellPlot, GenePlot, or DimPlot and its extensions (includes PCAPlot, TSNEPlot, etc.)

# Include additional data to display alongside cell names in data.hover
FeaturePlot(object = pbmc, features.plot = "MS4A1", do.hover = TRUE, data.hover = c("ident", 
    "PC1", "nGene"))

Manually select cells for further investigation. We have found this particularly useful for small clusters that do not always separate using unbiased clustering, but which look tantalizingly distinct. You can now select these cells by passing do.identify = TRUE to FeaturePlot or DimPlot and its extensions (includes PCAPlot, TSNEPlot, etc.). You can then set them to a new identity class and perform differential expression.

For example, lets pretend that DCs had merged with monocytes in the clustering, but we wanted to see what was unique about them based on their position in the tSNE plot.

pbmc <- RenameIdent(object = pbmc, old.ident.name = "Dendritic cells", new.ident.name = "CD14+ Monocytes")
select.cells <- TSNEPlot(object = pbmc, do.identify = TRUE)

We can then use SetIdent to turn these cells into their own mini-cluster.

head(select.cells)
## [1] "AAGATTACCGCCTT" "AAGCCATGAACTGC" "AATGCGTGGACGGA" "AATTACGAATTCCT"
## [5] "ACGAGGGACAGGAG" "ACGTGATGCCATGA"
pbmc <- SetIdent(object = pbmc, cells.use = select.cells, ident.use = "NewCells")

# Now, we find markers that are specific to the new cells, and find clear DC
# markers
newcells.markers <- FindMarkers(object = pbmc, ident.1 = "NewCells", ident.2 = "CD14+ Monocytes", 
    min.diff.pct = 0.3, only.pos = TRUE)
head(x = newcells.markers)
##                 p_val avg_logFC pct.1 pct.2    p_val_adj
## FCER1A   1.665710e-81 2.7128605 0.853 0.010 2.284354e-77
## HLA-DQB2 2.742465e-35 0.6859660 0.441 0.010 3.761017e-31
## CD1C     3.486797e-34 1.2535693 0.529 0.025 4.781794e-30
## SERPINF1 1.190504e-33 1.0475813 0.441 0.013 1.632658e-29
## ENHO     9.227248e-33 0.9701464 0.412 0.010 1.265425e-28
## CLEC10A  2.448149e-32 1.5865036 0.735 0.073 3.357391e-28