Load in the data

This vignette highlights some example workflows for performing differential expression in Seurat. For demonstration purposes, we will be using the 2,700 PBMC object that is created in the first guided tutorial. You can download the pre-computed object here.

library(Seurat)
pbmc <- readRDS(file = "../data/pbmc3k_final.rds")

Perform default differential expression tests

The bulk of Seurat’s differential expression features can be accessed through the FindMarkers function. As a default, Seurat performs differential expression based on the non-parameteric Wilcoxon rank sum test. This replaces the previous default test (‘bimod’). To test for differential expression between two specific groups of cells, specify the ident.1 and ident.2 parameters.

# list options for groups to perform differential expression on
levels(pbmc)
## [1] "Naive CD4 T"  "Memory CD4 T" "CD14+ Mono"   "B"            "CD8 T"       
## [6] "FCGR3A+ Mono" "NK"           "DC"           "Platelet"
# Find differentially expressed features between CD14+ and FCGR3A+ Monocytes
monocyte.de.markers <- FindMarkers(pbmc, ident.1 = "CD14+ Mono", ident.2 = "FCGR3A+ Mono")
# view results
head(monocyte.de.markers)
p_val avg_logFC pct.1 pct.2 p_val_adj
FCGR3A 0 -2.617707 0.131 0.975 0
LYZ 0 1.812078 1.000 0.988 0
RHOC 0 -1.611576 0.162 0.864 0
S100A8 0 2.610695 0.975 0.500 0
S100A9 0 2.286734 0.996 0.870 0
IFITM2 0 -1.445771 0.677 1.000 0

The results data frame has the following columns :

If the ident.2 parameter is omitted or set to NULL, FindMarkers will test for differentially expressed features between the group specified by ident.1 and all other cells.

# Find differentially expressed features between CD14+ Monocytes and all other cells, only
# search for positive markers
monocyte.de.markers <- FindMarkers(pbmc, ident.1 = "CD14+ Mono", ident.2 = NULL, only.pos = TRUE)
# view results
head(monocyte.de.markers)
p_val avg_logFC pct.1 pct.2 p_val_adj
S100A9 0 3.860873 0.996 0.215 0
S100A8 0 3.796640 0.975 0.121 0
LGALS2 0 2.634295 0.908 0.059 0
FCN1 0 2.352693 0.952 0.151 0
CD14 0 1.951644 0.667 0.028 0
TYROBP 0 2.111879 0.994 0.265 0

Prefilter features or cells to increase the speed of DE testing

To increase the speed of marker discovery, particularly for large datasets, Seurat allows for pre-filtering of features or cells. For example, features that are very infrequently detected in either group of cells, or features that are expressed at similar average levels, are unlikely to be differentially expressed. Example use cases of the min.pct, logfc.threshold, min.diff.pct, and max.cells.per.ident parameters are demonstrated below.

# Pre-filter features that are detected at <50% frequency in either CD14+ Monocytes or FCGR3A+
# Monocytes
head(FindMarkers(pbmc, ident.1 = "CD14+ Mono", ident.2 = "FCGR3A+ Mono", min.pct = 0.5))
p_val avg_logFC pct.1 pct.2 p_val_adj
FCGR3A 0 -2.617707 0.131 0.975 0
LYZ 0 1.812078 1.000 0.988 0
RHOC 0 -1.611576 0.162 0.864 0
S100A8 0 2.610695 0.975 0.500 0
S100A9 0 2.286734 0.996 0.870 0
IFITM2 0 -1.445771 0.677 1.000 0
# Pre-filter features that have less than a two-fold change between the average expression of
# CD14+ Monocytes vs FCGR3A+ Monocytes
head(FindMarkers(pbmc, ident.1 = "CD14+ Mono", ident.2 = "FCGR3A+ Mono", logfc.threshold = log(2)))
p_val avg_logFC pct.1 pct.2 p_val_adj
FCGR3A 0 -2.617707 0.131 0.975 0
LYZ 0 1.812078 1.000 0.988 0
RHOC 0 -1.611576 0.162 0.864 0
S100A8 0 2.610695 0.975 0.500 0
S100A9 0 2.286734 0.996 0.870 0
IFITM2 0 -1.445771 0.677 1.000 0
# Pre-filter features whose detection percentages across the two groups are similar (within
# 0.25)
head(FindMarkers(pbmc, ident.1 = "CD14+ Mono", ident.2 = "FCGR3A+ Mono", min.diff.pct = 0.25))
p_val avg_logFC pct.1 pct.2 p_val_adj
FCGR3A 0 -2.617707 0.131 0.975 0
RHOC 0 -1.611576 0.162 0.864 0
S100A8 0 2.610695 0.975 0.500 0
IFITM2 0 -1.445771 0.677 1.000 0
LGALS2 0 2.049431 0.908 0.265 0
CDKN1C 0 -1.007729 0.029 0.506 0
# Increasing min.pct, logfc.threshold, and min.diff.pct, will increase the speed of DE testing,
# but could also miss features that are prefiltered

# Subsample each group to a maximum of 200 cells. Can be very useful for large clusters, or
# computationally-intensive DE tests
head(FindMarkers(pbmc, ident.1 = "CD14+ Mono", ident.2 = "FCGR3A+ Mono", max.cells.per.ident = 200))
p_val avg_logFC pct.1 pct.2 p_val_adj
FCGR3A 0 -2.6177073 0.131 0.975 0
LYZ 0 1.8120776 1.000 0.988 0
S100A8 0 2.6106955 0.975 0.500 0
S100A9 0 2.2867339 0.996 0.870 0
IFITM2 0 -1.4457715 0.677 1.000 0
RPS19 0 -0.7563274 0.990 1.000 0

Perform DE analysis using alternative tests

The following differential expression tests are currently supported:

For MAST and DESeq2 please ensure that these packages are installed separately in order to use them as part of Seurat. Once installed, use the test.use parameter can be used to specify which DE test to use.

# Test for DE features using the MAST package
head(FindMarkers(pbmc, ident.1 = "CD14+ Mono", ident.2 = "FCGR3A+ Mono", test.use = "MAST"))
p_val avg_logFC pct.1 pct.2 p_val_adj
LYZ 0 1.812078 1.000 0.988 0
FCGR3A 0 -2.617707 0.131 0.975 0
S100A9 0 2.286734 0.996 0.870 0
S100A8 0 2.610695 0.975 0.500 0
IFITM2 0 -1.445771 0.677 1.000 0
LGALS2 0 2.049431 0.908 0.265 0
# Test for DE features using the DESeq2 package. Throws an error if DESeq2 has not already been
# installed Note that the DESeq2 workflows can be computationally intensive for large datasets,
# but are incompatible with some feature pre-filtering options We therefore suggest initially
# limiting the number of cells used for testing
head(FindMarkers(pbmc, ident.1 = "CD14+ Mono", ident.2 = "FCGR3A+ Mono", test.use = "DESeq2", max.cells.per.ident = 50))
p_val avg_logFC pct.1 pct.2 p_val_adj
S100A9 0 1.759457 0.996 0.870 0
LYZ 0 1.377950 1.000 0.988 0
S100A8 0 1.929894 0.975 0.500 0
FCGR3A 0 -2.044779 0.131 0.975 0
RPS19 0 -1.119358 0.990 1.000 0
IFITM2 0 -1.533646 0.677 1.000 0

Acknowledgements

We thank the authors of the MAST and DESeq2 packages for their kind assistance and advice. We also point users to the following study by Charlotte Soneson and Mark Robinson, which performs careful and extensive evaluation of methods for single cell differential expression testing.