scCustomize包由来自波士顿儿童医院/哈佛医学院的博士后Samuel E. Marsh编写。该包基于Seurat,提供了若干便捷、高效的可视化方法。根据官方教程学习其中感兴趣的用法。

0、示例数据

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
sce <- pbmc3k.SeuratData::pbmc3k.final
sce$sample_id <- sample(c("sample1", "sample2", "sample3"), size = ncol(sce),
                        replace = TRUE)
sce$treatment <- sample(c("before", "after"), size = ncol(sce),
                        replace = TRUE)
sce = sce %>%
  NormalizeData() %>%
  FindVariableFeatures() %>%
  ScaleData()
sce = sce %>% 
  RunPCA() %>% 
  RunUMAP(dims = 1:30) %>%  #RunTSNE
  FindNeighbors(dims = 1:30) %>% 
  FindClusters(resolution = c(0.01, 0.05, 0.1, 0.2, 0.3, 0.5,0.8,1))

1、高变基因

  • 可设置参数,加标签
1
2
VariableFeaturePlot_scCustom(seurat_object = sce, num_features = 5,
	label = TRUE, repel = TRUE)
image-20230311100611148

2、小提琴图

1
2
3
4
5
6
7
Idents(sce) = "RNA_snn_res.0.01"
gene_list_plot <- VariableFeatures(sce)[1:5]
p1 = Stacked_VlnPlot(seurat_object = sce, features = gene_list_plot, x_lab_rotate = TRUE)
p2 = Stacked_VlnPlot(seurat_object = sce, features = gene_list_plot, plot_spacing = 0.3)
p3 = Stacked_VlnPlot(seurat_object = sce, features = gene_list_plot, split.by = "sample_id")
p4 = Stacked_VlnPlot(seurat_object = sce, features = gene_list_plot, split.by = "treatment", split.plot=TRUE)
(p1 | p2) / (p3 | p4)
image-20230311101113151

3、聚类点图

1
2
3
4
5
6
7
8
Idents(sce) = "RNA_snn_res.0.2"
all_markers <- FindAllMarkers(object = sce)

top5_markers <- Extract_Top_Markers(marker_dataframe = all_markers, num_genes = 5, named_vector = FALSE,
    make_unique = TRUE)

Clustered_DotPlot(seurat_object = sce, features = top5_markers)         # 左
Clustered_DotPlot(seurat_object = sce, features = top5_markers, k = 6)  # 右
image-20230311101732460

4、降维相关可视化

  • (1)FeaturePlot_scCustom:低于特定阈值的基因不映射连续颜色
1
FeaturePlot_scCustom(seurat_object = sce, features = "PTPRC", na_cutoff=2)
image-20230311102026932
  • (2)DimPlot_scCustom:迷你版坐标轴
1
DimPlot_scCustom(seurat_object = sce, figure_plot = TRUE)
image-20230311102302668
  • (3)Cluster_Highlight_Plot:单独显示特定细胞群
1
2
3
4
5
6
Idents(sce) = "RNA_snn_res.0.1"
p1 = Cluster_Highlight_Plot(seurat_object = sce, cluster_name = "0", highlight_color = "red",
    background_color = "lightgray")
p2 = Cluster_Highlight_Plot(seurat_object = sce, cluster_name = c(2,3), highlight_color = c("red","blue"),
    background_color = "lightgray")
p1 | p2
image-20230311102505649

5、自定义颜色

  • (1)连续型变量:默认为viridis_plasma_dark_high,其它可选包括
    • viridis_plasma_light_high
    • viridis_magma_dark_high
    • viridis_magma_light_high
    • viridis_inferno_dark_high
    • viridis_inferno_light_high
    • viridis_dark_high
    • viridis_light_high
1
2
PalettePlot(pal = viridis_plasma_dark_high)
# FeaturePlot_scCustom(seurat_object = sce, colors_use = viridis_magma_dark_high, features = "CD3E")

image-20230311103035497

  • (2)离散型变量:单变量-“dodgerblue”;双变量-NavyAndOrange();<36-“polychrome”;>36–“varibow”(shuffle)。其它包括
    • alphabet (24)
    • alphabet2 (24)
    • glasbey (32)
    • polychrome (36)
    • stepped (24)
    • ditto_seq (40)
    • varibow (Dynamic)
1
PalettePlot(pal = DiscretePalette_scCustomize(num_colors = 10, palette = "polychrome"))

image-20230311103540378

1
PalettePlot(pal = DiscretePalette_scCustomize(num_colors = 10, palette = "ditto_seq", shuffle_pal = TRUE))

image-20230311103655746