ixxmu / mp_duty

抓取网络文章到github issues保存
https://archives.duty-machine.now.sh/
106 stars 30 forks source link

单细胞分析工具-scCustomize包改进Seurat可视化 #3256

Closed ixxmu closed 1 year ago

ixxmu commented 1 year ago

https://mp.weixin.qq.com/s/Y8sPLN05SKXHtjFQtFTBrA

ixxmu commented 1 year ago

单细胞分析工具-scCustomize包改进Seurat可视化 by 单细胞天地


分享是一种态度

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

  • https://github.com/samuel-marsh/scCustomize/
  • https://samuel-marsh.github.io/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.010.050.10.20.30.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_magma_dark_high
    • viridis_magma_light_high
    • viridis_inferno_dark_high
    • viridis_inferno_light_high
    • viridis_dark_high
    • viridis_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)。其它包括
    • alphabet (24)
    • alphabet2 (24)
    • glasbey (32)
    • polychrome (36)
    • stepped (24)
    • ditto_seq (40)
    • varibow (Dynamic)
PalettePlot(pal = DiscretePalette_scCustomize(num_colors = 10, palette = "polychrome"))
PalettePlot(pal = DiscretePalette_scCustomize(num_colors = 10, palette = "ditto_seq", shuffle_pal = TRUE))



往期回顾

单细胞测序揭示肝癌免疫微环境和中性粒细胞异质性

单细胞多组学ATAC-Cellranger ARC-结果解读之表达矩阵Feature-Barcode Matrices

单细胞分析工具--MAST差异基因分析

数据分析小技巧 | 提取cellranger质控信息需仔细






如果你对单细胞转录组研究感兴趣,但又不知道如何入门,也许你可以关注一下下面的课程



看完记得顺手点个“在看”哦!


生物 | 单细胞 | 转录组丨资料
每天都精彩

长按扫码可关注