这个教程突出显示了在Seurat中执行差异表达式的一些示例工作流。出于演示目的,我们将使用第一个向导教程中创建的2700个PBMC对象。
执行默认的差异分析
Seurat的大部分差异表达式特性都可以通过findmarker函数访问。默认情况下,Seurat基于非参数Wilcoxon秩和检验执行差异分析。这将替换以前的默认测试(' bimod ')。若要测试两组特定细胞之间的差异表达,ident.1 and ident.2。
library(Seurat)
library(ggplot2)
pbmc <- readRDS(file = "D:\\Users\\Administrator\\Desktop\\Novo周运来\\SingleCell\\scrna_tools/pbmc3k_final.rds")
# list options for groups to perform differential expression on
levels(pbmc)
[1] "Naive CD4 T" "Memory CD4 T" "CD14+ Mono" "B"
[5] "CD8 T" "FCGR3A+ Mono" "NK" "DC"
[9] "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 1.221183e-111 -2.960870 0.049 0.975 1.674731e-107
IFITM3 3.799566e-110 -2.706276 0.051 0.975 5.210725e-106
CFD 1.051493e-108 -2.415630 0.030 0.938 1.442018e-104
FCER1G 1.608504e-108 -3.358616 0.100 1.000 2.205903e-104
TYROBP 3.503255e-103 -3.294981 0.144 1.000 4.804364e-99
CD68 7.439840e-103 -2.104813 0.046 0.926 1.020300e-98
结果数据框架有以下列:
- p_val: p_val(未调整)
- avg_logFC:两组间平均logFC。正值表示特征在第一组中表达得更高。
- pct.1 :在第一组中检测到该特征的cell的百分比
- pct.2 :在第二组中检测到该特征的cell的百分比
- p_val_adj:调整p值,基于bonferroni校正使用数据集中的所有功能。
# 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)
head(monocyte.de.markers)
p_val avg_logFC pct.1 pct.2 p_val_adj
IL32 1.666248e-81 0.7904889 0.951 0.474 2.285092e-77
LTB 2.610564e-81 0.8857289 0.981 0.650 3.580128e-77
LDHB 1.142971e-65 0.6517270 0.968 0.618 1.567470e-61
CD3D 7.634892e-62 0.6077867 0.917 0.442 1.047049e-57
IL7R 6.620193e-61 0.8088807 0.750 0.335 9.078933e-57
CD2 1.223464e-59 0.8861585 0.669 0.250 1.677858e-55
预过基因或者细胞,以提高DE测试的速度
为了提高标记发现的速度,特别是对于大型数据集,Seurat允许对特征或cell进行预过滤。例如,在两组细胞中都很少检测到的特征,或者在相似的平均水平上表达的特征,不太可能有差异表达。min.pct、logfc的示例用例。阈值,min.diff。pct和max.cells.per。ident参数如下所示。
# 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))
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=08s
p_val avg_logFC pct.1 pct.2 p_val_adj
FCGR3A 1.221183e-111 -2.960870 0.049 0.975 1.674731e-107
IFITM3 3.799566e-110 -2.706276 0.051 0.975 5.210725e-106
CFD 1.051493e-108 -2.415630 0.030 0.938 1.442018e-104
FCER1G 1.608504e-108 -3.358616 0.100 1.000 2.205903e-104
TYROBP 3.503255e-103 -3.294981 0.144 1.000 4.804364e-99
CD68 7.439840e-103 -2.104813 0.046 0.926 1.020300e-98
# 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)))
6s
p_val avg_logFC pct.1 pct.2 p_val_adj
FCGR3A 1.221183e-111 -2.960870 0.049 0.975 1.674731e-107
IFITM3 3.799566e-110 -2.706276 0.051 0.975 5.210725e-106
CFD 1.051493e-108 -2.415630 0.030 0.938 1.442018e-104
FCER1G 1.608504e-108 -3.358616 0.100 1.000 2.205903e-104
TYROBP 3.503255e-103 -3.294981 0.144 1.000 4.804364e-99
CD68 7.439840e-103 -2.104813 0.046 0.926 1.020300e-98
# 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))
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=07s
p_val avg_logFC pct.1 pct.2 p_val_adj
FCGR3A 1.221183e-111 -2.960870 0.049 0.975 1.674731e-107
IFITM3 3.799566e-110 -2.706276 0.051 0.975 5.210725e-106
CFD 1.051493e-108 -2.415630 0.030 0.938 1.442018e-104
FCER1G 1.608504e-108 -3.358616 0.100 1.000 2.205903e-104
TYROBP 3.503255e-103 -3.294981 0.144 1.000 4.804364e-99
CD68 7.439840e-103 -2.104813 0.046 0.926 1.020300e-98
# 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))
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=16s
p_val avg_logFC pct.1 pct.2 p_val_adj
FCER1G 9.932112e-69 -3.358616 0.100 1.000 1.362090e-64
TYROBP 6.640266e-68 -3.294981 0.144 1.000 9.106461e-64
AIF1 1.559285e-66 -3.210036 0.185 1.000 2.138403e-62
FCGR3A 3.389538e-66 -2.960870 0.049 0.975 4.648412e-62
IFITM3 5.490079e-66 -2.706276 0.051 0.975 7.529094e-62
LST1 7.587752e-65 -3.265432 0.213 1.000 1.040584e-60
Perform DE analysis using alternative tests
The following differential expression tests are currently supported:
- “wilcox” : Wilcoxon rank sum test (default)
- “bimod” : Likelihood-ratio test for single cell feature expression, (McDavid et al., Bioinformatics, 2013)
- “roc” : Standard AUC classifier
- “t” : Student’s t-test
- “poisson” : Likelihood ratio test assuming an underlying negative binomial distribution. Use only for UMI-based datasets
- “negbinom” : Likelihood ratio test assuming an underlying negative binomial distribution. Use only for UMI-based datasets
- “LR” : Uses a logistic regression framework to determine differentially expressed genes. Constructs a logistic regression model predicting group membership based on each feature individually and compares this to a null model with a likelihood ratio test.
- “MAST” : GLM-framework that treates cellular detection rate as a covariate (Finak et al, Genome Biology, 2015) (Installation instructions)
- “DESeq2” : DE based on a model using the negative binomial distribution (Love et al, Genome Biology, 2014) (Installation instructions)
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"))
Assuming data assay in position 1, with name et is log-transformed.
Done!
Combining coefficients and standard errors
Calculating log-fold changes
Calculating likelihood ratio tests
Refitting on reduced model...
Done!
p_val avg_logFC pct.1 pct.2 p_val_adj
FTL 1.639548e-249 -2.647647 0.993 1 2.248476e-245
FTH1 2.783216e-242 -2.219687 1.000 1 3.816902e-238
AIF1 7.652245e-202 -3.210036 0.185 1 1.049429e-197
CST3 2.169655e-191 -3.253608 0.231 1 2.975465e-187
LST1 3.128135e-191 -3.265432 0.213 1 4.289924e-187
TYROBP 3.898825e-179 -3.294981 0.144 1 5.346848e-175
# 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))
converting counts to integer mode
gene-wise dispersion estimates
mean-dispersion relationship
final dispersion estimates
p_val avg_logFC pct.1 pct.2 p_val_adj
FTL 5.228822e-270 -2.852609 0.993 1 7.170807e-266
FTH1 4.012123e-230 -2.428191 1.000 1 5.502225e-226
TYROBP 3.206815e-93 -2.631490 0.144 1 4.397826e-89
FCER1G 3.419275e-89 -2.660790 0.100 1 4.689194e-85
CST3 2.334414e-84 -2.739375 0.231 1 3.201416e-80
AIF1 7.077034e-81 -2.626784 0.185 1 9.705445e-77
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.