更多重要函數(shù)見:Seurat重要命令匯總
Seurat繪圖函數(shù)總結(jié)
在使用R語言進行單細胞數(shù)據(jù)的分析和處理時昨稼,除了優(yōu)秀的繪圖包ggplot2以外叶沛,Seurat也自帶一些優(yōu)秀的可視化工具侣姆,可以用于各種圖形繪制耽梅。
Seurat圖形繪制函數(shù) | Single gene | Multiple gene | Dimention Reduction | Cluster Information |
---|---|---|---|---|
RidgePlot | ? | ? | ||
VlnPlot | ? | ? | ||
FeaturePlot | ? | ? | ||
DotPlot | ? | ? | ||
DoHeatmap | ? | ? | ||
FeatureScatter | ? | ? | ||
Dimplot | ? | ? |
演示:
示例數(shù)據(jù)集見monocle中的pbmc3k蹲坷,并按代碼做好注釋和保存槽畔。
1. RidgePlot山脊圖
library(Seurat)
library(tidyverse)
library(patchwork)
rm(list=ls())
dir.create("visual")
pbmc <- readRDS("pbmc.rds")
p1 = RidgePlot(pbmc, features = "FCN1")
p2 = RidgePlot(pbmc, features = "PC_2")
plotc = p1/p2 + plot_layout(guides = 'collect')
ggsave('ridgeplot.png', plotc, width = 10,height = 8)
在山脊圖中趾浅,features參數(shù)設置繪制的對象闰挡,可以是基因(查看表達情況),矩陣析校,PC評分等等可以被FetchData()取出的對象构罗。
上圖中,縱軸是細胞類型智玻,原因是該演示數(shù)據(jù)集已注釋好遂唧,且細胞類型注釋被加入到active.ident中,因此在進行設置時吊奢,默認繪制對各個細胞類型進行繪制盖彭。可以使用group.by參數(shù)進行更改页滚。
p1 = RidgePlot(pbmc, features = "FCN1",group.by = 'seurat_clusters')
p2 = RidgePlot(pbmc, features = "PC_2",group.by = 'seurat_clusters')
plotc = p1/p2 + plot_layout(guides = 'collect')
ggsave('ridgeplot2.png', plotc, width = 10,height = 8)
2. VlnPlot
p1 = VlnPlot(pbmc, features = "nCount_RNA", pt.size = 0,group.by = 'seurat_clusters')
p2 = VlnPlot(pbmc, features = "CD8A", pt.size = 0)
plotc = p1/p2 + plot_layout(guides = 'collect')
ggsave('vlnplot.png', plotc, width = 8,height = 8)
3. FeaturePlot
p1 <- FeaturePlot(pbmc,features = "CD8A", reduction = 'umap')
p2 <- FeaturePlot(pbmc,features = "CCL2", reduction = 'pca')
plotc = p1|p2
ggsave('featureplot.png', plotc, width = 10, height = 4)
對顏色閾值進行設置
p1=FeaturePlot(pbmc, features = "MS4A1")
p2=FeaturePlot(pbmc, features = "MS4A1", min.cutoff = 1, max.cutoff = 3)
p1|p2
在一張圖里查看兩種marker
FeaturePlot(pbmc, features = c("MS4A1", "CD79A"), blend = TRUE)
4. DotPlot
genelist = c('LYZ','CD79A','CD8A','CD8B','GZMB','FCGR3A')
p = DotPlot(pbmc, features = genelist)
ggsave('dotplot.png', p, width =8, height = 5)
5. DoHeatmap
對聚類分析后鑒定到的每一個分群后進行差異基因鑒定后召边,每個群選擇可以top10的差異基因做的熱圖展示(熱圖畫的是scale后的@scale.data)。
6. FeatureScatter
p1 <- FeatureScatter(pbmc, feature1 = 'PC_1', feature2 = 'PC_2')
p2 <- FeatureScatter(pbmc, feature1 = 'nCount_RNA', feature2 = 'nFeature_RNA')
plotc = p1|p2
ggsave('featurescatter.png', plotc, width = 10, height = 4)
FeatureScatter還可以用來查看所有細胞或某個細胞中兩個基因的相關性
p1=FeatureScatter(pbmc, feature1 = "LYZ", feature2 = "CCL5")
p2=FeatureScatter(pbmc, feature1 = "S100A8", feature2 = "S100A9")
p1|p2
7. Dimplot
p1 <- DimPlot(pbmc, reduction = 'pca', group.by = "cell_type", label=T)
p2 <- DimPlot(pbmc, reduction = 'umap', group.by = "seurat_clusters", label=T)
plotc = p1|p2
ggsave('dimplot.png', plotc, width = 10, height = 4)
8. 交互式繪圖
先查看一下所有細胞的注釋
DimPlot(pbmc)
如果對某一群細胞感興趣裹驰,可以直接圈出來
select.cells <- CellSelector(plot = plot)
直接手動圈出來想要的細胞隧熙,再點Done
head(select.cells)
# [1] "AAACCGTGTATGCG-1" "AAATTCGATTCTCA-1" "AAATTGACACGACT-1"
# [4] "AACCTTACGCGAGA-1" "AACGCCCTCGTACA-1" "AACGTCGAGTATCG-1"
Idents(pbmc, cells = select.cells) <- "NewCells"
# 如果這一群細胞和CD14+ Mono細胞區(qū)分不開,就可以找這群細胞和CD14+ Mono相比的特異性marker了
newcells.markers <- FindMarkers(pbmc, ident.1 = "NewCells", ident.2 = "CD14+ Mono", min.diff.pct = 0.3,
only.pos = TRUE)
head(newcells.markers)
參考:https://satijalab.org/seurat/archive/v3.2/visualization_vignette.html