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

0、示例数据
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、高变基因
VariableFeaturePlot_scCustom(seurat_object = sce, num_features = 5,
label = TRUE, repel = TRUE)

2、小提琴图
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)

3、聚类点图
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) # 右

4、降维相关可视化
- (1)FeaturePlot_scCustom:低于特定阈值的基因不映射连续颜色
FeaturePlot_scCustom(seurat_object = sce, features = "PTPRC", na_cutoff=2)

- (2)DimPlot_scCustom:迷你版坐标轴
DimPlot_scCustom(seurat_object = sce, figure_plot = TRUE)

- (3)Cluster_Highlight_Plot:单独显示特定细胞群
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

5、自定义颜色
- (1)连续型变量:默认为
viridis_plasma_dark_high
,其它可选包括 viridis_plasma_light_high
viridis_inferno_dark_high
viridis_inferno_light_high
PalettePlot(pal = viridis_plasma_dark_high)
# FeaturePlot_scCustom(seurat_object = sce, colors_use = viridis_magma_dark_high, features = "CD3E")

- (2)离散型变量:单变量-"dodgerblue";双变量-NavyAndOrange();<36-"polychrome";>36--"varibow"(shuffle)。其它包括
PalettePlot(pal = DiscretePalette_scCustomize(num_colors = 10, palette = "polychrome"))

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