美文网首页单细胞测序scRNA-seqR for statistics
Seurat绘图函数总结(更新版)

Seurat绘图函数总结(更新版)

作者: Hayley笔记 | 来源:发表于2021-05-02 12:36 被阅读0次

    更多重要函数见:Seurat重要命令汇总

    Seurat绘图函数总结

    在使用R语言进行单细胞数据的分析和处理时,除了优秀的绘图包ggplot2以外,Seurat也自带一些优秀的可视化工具,可以用于各种图形绘制。

    Seurat图形绘制函数 Single gene Multiple gene Dimention Reduction Cluster Information
    RidgePlot
    VlnPlot
    FeaturePlot
    DotPlot
    DoHeatmap
    FeatureScatter
    Dimplot

    演示:

    示例数据集见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参数设置绘制的对象,可以是基因(查看表达情况),矩阵,PC评分等等可以被FetchData()取出的对象。
    上图中,纵轴是细胞类型,原因是该演示数据集已注释好,且细胞类型注释被加入到active.ident中,因此在进行设置时,默认绘制对各个细胞类型进行绘制。可以使用group.by参数进行更改。

    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细胞区分不开,就可以找这群细胞和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

    相关文章

      网友评论

        本文标题:Seurat绘图函数总结(更新版)

        本文链接:https://www.haomeiwen.com/subject/hyjtdltx.html