jamesbang

V1

2023/04/22阅读：28主题：雁栖湖

🧐 Scillus | 来吧！它可以大大简化你的Seurat分析流程哦！~（二）（高级可视化）

2用到的包

``rm(list = ls())library(tidyverse)library(Scillus)library(Seurat)library(magrittr)library(purrr)``

3示例数据

``load("./scRNA_scillus.Rdata")scRNA_int``

4降维及其可视化

4.1 初步绘图

``plot_scdata(scRNA_int, pal_setup = pal)``

4.2 换个主题配色

``plot_scdata(scRNA_int, pal_setup = "Dark2")``

4.3 分组可视化

``plot_scdata(scRNA_int, color_by = "group", pal_setup = pal)``

4.4 分面可视化

``plot_scdata(scRNA_int, split_by = "sample", pal_setup = pal)``

4.5 手动配色

``plot_scdata(scRNA_int, color_by = "sample",             pal_setup = c("red","orange","yellow","green","blue","purple"))``

5统计及其可视化

5.1 按sample统计

``plot_stat(scRNA_int,           plot_type = "group_count"          ## 三种，"group_count", "prop_fill", and "prop_multi"          )``

5.2 按cluster统计

``plot_stat(scRNA_int, "group_count", group_by = "seurat_clusters", pal_setup = pal)``

5.3 堆叠柱形图

``plot_stat(scRNA_int,           plot_type = "prop_fill",           pal_setup = c("grey90","grey80","grey70","grey60","grey50","grey40","grey30","grey20"))``

5.4 按cluster和sample统计

``plot_stat(scRNA_int, plot_type = "prop_multi", pal_setup = "Set3")``

5.5 按cluster和group统计

``plot_stat(scRNA_int, plot_type = "prop_fill", group_by = "group")``

5.6 换个配色

``plot_stat(scRNA_int, plot_type = "prop_multi",           group_by = "group", pal_setup = c("sienna","bisque3"))``

6热图及其可视化

6.1 寻找marker

``markers <- FindAllMarkers(scRNA_int, logfc.threshold = 0.25, min.pct = 0.1, only.pos = F)``

6.2 热图可视化

`anno_var`用来指定注释数据或者`metadata`中的相关数据。🥰

``plot_heatmap(dataset = scRNA_int,               markers = markers,              sort_var = c("seurat_clusters","sample"),              anno_var = c("seurat_clusters","sample","percent.mt","S.Score","G2M.Score"),              anno_colors = list("Set2",                                                                              # RColorBrewer palette                                 c("red","orange","yellow","purple","blue","green"),                                  # color vector                                 "Reds",                                 c("blue","white","red"),                                                             # Three-color gradient                                 "Greens"))``

6.3 调整热图

``plot_heatmap(dataset = scRNA_int,             n = 6,             markers = markers,             sort_var = c("seurat_clusters","sample"),             anno_var = c("seurat_clusters","sample","percent.mt"),             anno_colors = list("Set2",                                c("red","orange","yellow","purple","blue","green"),                                "Reds"),             hm_limit = c(-1,0,1),             hm_colors = c("purple","black","yellow"))``

7富集分析

7.1 制定cluster的GO分析

``plot_cluster_go(markers, cluster_name = "1", org = "human", ont = "CC")``

7.2 所有cluster的GO分析

``plot_all_cluster_go(markers, org = "human", ont = "BP")``

8GSEA分析

8.1 差异分析

``de <- find_diff_genes(dataset = scRNA_int,                       clusters = as.character(0:7),                      comparison = c("group", "CTCL", "Normal"),                      logfc.threshold = 0,   # threshold of 0 is used for GSEA                      min.cells.group = 1)   # To include clusters with only 1 cellgsea_res <- test_GSEA(de,                       pathway = pathways.hallmark)``

8.2 GSEA结果可视化

``plot_GSEA(gsea_res, p_cutoff = 0.1, colors = c("#0570b0", "grey", "#d7301f"))``

9补充一下

`Scillus`包中有一个非常好用的功能叫`Plotting Measures`，在这里补充一下。😜

9.1 小试牛刀

``plot_measure(dataset = scRNA_int,              measures = c("KRT14","percent.mt"),              group_by = "seurat_clusters",              pal_setup = pal)``

9.2 更进一步

``plot_measure_dim(dataset = scRNA_int,                  measures = c("nFeature_RNA","nCount_RNA","percent.mt","KRT14"),                 split_by = "sample")``

📍 往期精彩

jamesbang
V1

wx🔍: Grassssss 卷起来了