Seurat新版教程:New data visualization methods in v3.0

导读

本文介绍了新版Seurat在数据可视化方面的新功能。主要是进一步加强与ggplot2语法的兼容性,支持交互操作。

正文

seurat visualization
(https://satijalab.org/seurat/v3.1/visualization_vignette.html)

我们将使用之前在2700 PBMC教程中计算的Seurat对象演示Seurat中的可视化技术。你可以在这里下载here

(https://uc66f7da0336d5812fa5d2ac2b5c.dl.dropboxusercontent.com/cd/0/get/Ap7GVuEY1T6_xKRzBNq5pmGQd7YoBw0hYlkpDsMsvnBvOqXpZrrpLLoBLBUhzLemy8tF-iTOoyM43Pf4kUGHaqJVZhUS696Jru8ITQzKi39fdQ/file?dl=1#)

1ibrary(Seurat)
2library(ggplot2)
3pbmc <- readRDS(file = "D:\\Users\\Administrator\\Desktop\\Novo周运来\\SingleCell\\scrna_tools/pbmc3k_final.rds")
4pbmc$groups <- sample(c("group1", "group2"), size = ncol(pbmc), replace = TRUE)
5features <- c("LYZ", "CCL5", "IL32", "PTPRCAP", "FCGR3A", "PF4")
6pbmc
7
8An object of class Seurat 
913714 features across 2638 samples within 1 assay 
10Active assay: RNA (13714 features)
11 3 dimensional reductions calculated: pca, umap, tsne

five-visualizations-of-marker-feature-expression

1# Ridge plots - from ggridges. Visualize single cell expression distributions in each cluster
2RidgePlot(pbmc, features = features, ncol = 2)

1# Violin plot - Visualize single cell expression distributions in each cluster
2VlnPlot(pbmc, features = features)

1# Feature plot - visualize feature expression in low-dimensional space
2FeaturePlot(pbmc, features = features)

1# Dot plots - the size of the dot corresponds to the percentage of cells expressing the feature
2# in each cluster. The color represents the average expression level
3DotPlot(pbmc, features = features) + RotatedAxis()

1# Single cell heatmap of feature expression
2DoHeatmap(subset(pbmc, downsample = 100), features = features, size = 3)

new-additions-to-featureplot

1# Plot a legend to map colors to expression levels
2FeaturePlot(pbmc, features = "MS4A1")

1# Adjust the contrast in the plot
2FeaturePlot(pbmc, features = "MS4A1", min.cutoff = 1, max.cutoff = 3)

1# Calculate feature-specific contrast levels based on quantiles of non-zero expression.
2# Particularly useful when plotting multiple markers
3FeaturePlot(pbmc, features = c("MS4A1", "PTPRCAP"), min.cutoff = "q10", max.cutoff = "q90")

1# Visualize co-expression of two features simultaneously
2FeaturePlot(pbmc, features = c("MS4A1", "CD79A"), blend = TRUE)

1# Split visualization to view expression by groups (replaces FeatureHeatmap)
2FeaturePlot(pbmc, features = c("MS4A1", "CD79A"), split.by = "groups")

updated-and-expanded-visualization-functions

除了对FeaturePlot进行更改外,还更新和扩展了其他几个绘图函数,添加了一些新特性,并取代了现在不推荐的函数.

1# Violin plots can also be split on some variable. Simply add the splitting variable to object
2# metadata and pass it to the split.by argument
3VlnPlot(pbmc, features = "percent.mt", split.by = "groups")

1# SplitDotPlotGG has been replaced with the `split.by` parameter for DotPlot
2DotPlot(pbmc, features = features, split.by = "groups") + RotatedAxis()

1# DimPlot replaces TSNEPlot, PCAPlot, etc. In addition, it will plot either 'umap', 'tsne', or
2# 'pca' by default, in that order
3DimPlot(pbmc)

1pbmc.no.umap <- pbmc
2pbmc.no.umap[["umap"]] <- NULL
3DimPlot(pbmc.no.umap) + RotatedAxis()

1# DoHeatmap now shows a grouping bar, splitting the heatmap into groups or clusters. This can be
2# changed with the `group.by` parameter
3DoHeatmap(pbmc, features = VariableFeatures(pbmc)[1:100], cells = 1:500, size = 4, angle = 90) + 
4    NoLegend()

applying-themes-to-plots

在Seurat v3.0中,所有绘图函数默认情况下都返回基于ggplot2的绘图对象,允许我们像其他基于ggplot2的绘图对象一样轻松地再次操作绘图。

1baseplot <- DimPlot(pbmc, reduction = "umap")
2# Add custom labels and titles
3baseplot + labs(title = "Clustering of 2,700 PBMCs")

1# Use community-created themes, overwriting the default Seurat-applied theme Install ggmin with
2# devtools::install_github('sjessa/ggmin')
3baseplot + ggmin::theme_powerpoint()

1# Seurat also provides several built-in themes, such as DarkTheme; for more details see
2# ?SeuratTheme
3baseplot + DarkTheme()

1# Chain themes together
2baseplot + FontSize(x.title = 20, y.title = 20) + NoLegend()

interactive-plotting-features

Seurat利用R的plot绘图库来创建交互式绘图。这个交互式绘图功能适用于任何基于ggplot2的散点图(需要一个geom_point层)。要使用它,只需制作一个基于ggplot2的散点图(例如DimPlot或FeaturePlot),并将生成的图传递给HoverLocator.

1# Include additional data to display alongside cell names by passing in a data frame of
2# information Works well when using FetchData
3plot <- FeaturePlot(pbmc, features = "MS4A1")

1HoverLocator(plot = plot, information = FetchData(pbmc, vars = c("ident", "PC_1", "nFeature_RNA")))
2Warning messages:
31: In if (is.na(col)) { :
4  the condition has length > 1 and only the first element will be used
52: In if (is.na(col)) { :
6  the condition has length > 1 and only the first element will be used
73: `error_y.color` does not currently support multiple values. 
84: `error_x.color` does not currently support multiple values. 
95: `line.color` does not currently support multiple values. 
106: The titlefont attribute is deprecated. Use title = list(font = ...) instead. 

更多细节等你探索,交互式Seurat!

Seurat提供的另一个交互特性是能够手动选择细胞以进行进一步的研究。我们发现,对于那些并不总是使用无偏聚类进行分离的小集群来说,这一点特别有用,但是它们看起来非常不同。现在,您可以通过创建一个基于ggplot2的散点图(例如使用DimPlot或FeaturePlot,并将返回的图传递给CellSelector)来选择这些细胞。CellSelector将返回一个向量,其中包含所选点的名称,这样您就可以将它们设置为一个新的标识类进行 differential expression。

例如,让我们假设树突状细胞(DCs)已经在集群中与单核细胞(monocytes)合并,但是我们想根据它们在tSNE图中的位置了解它们的独特之处。

1pbmc <- RenameIdents(pbmc, DC = "CD14+ Mono")
2plot <- DimPlot(pbmc, reduction = "umap")
3select.cells <- CellSelector(plot = plot)

给出一行小提示:

1Click around the cluster of points you wish to select
2ie. select the vertecies of a shape around the cluster you
3are interested in. Press <Esc> when finished (right click for R-terminal users)

然后我们可以使用SetIdent将这些细胞转变成它们自己的小簇。

1> head(select.cells)
2[1] "AAGCCATGAACTGC" "ACGTCGCTCCTGAA" "ACTTAAGATTACTC"
3[4] "ACTTCAACAAGCAA" "AGCACTGATGCTTT" "CACCGGGACTTCTA"
1Idents(pbmc, cells = select.cells) <- "NewCells"
2
3# Now, we find markers that are specific to the new cells, and find clear DC markers
4newcells.markers <- FindMarkers(pbmc, ident.1 = "NewCells", ident.2 = "CD14+ Mono", min.diff.pct = 0.3, 
5                                only.pos = TRUE)
6head(newcells.markers)
1                p_val avg_logFC pct.1 pct.2    p_val_adj
2HLA-DQA2 6.579989e-24  1.635741 0.619 0.045 9.023796e-20
3SPECC1   1.928970e-21  0.547701 0.333 0.009 2.645390e-17
4FCER1A   3.069126e-21  2.062739 0.524 0.036 4.208999e-17
5HLA-DQB1 1.476429e-20  1.823891 0.905 0.142 2.024774e-16
6HLA-DRB5 3.013802e-20  1.994758 0.810 0.112 4.133129e-16
7HLA-DMA  6.237886e-20  1.363932 0.762 0.092 8.554637e-16

除了返回一个向量的细胞名称,CellSelector也可以选择的细胞和分配一个新的身份,返回一个修对象与身份已经设置类。这样做是通过修对象用来制造阴谋CellSelector,以及身份类。例如,我们将选择与之前相同的单元格集合,并将它们的标识类设置为" selected "

1pbmc <- CellSelector(plot = plot, object = pbmc, ident = "selected")
2levels(pbmc)
3[1] "selected"     "NewCells"     "CD14+ Mono"   "Naive CD4 T" 
4 [5] "Memory CD4 T" "B"            "CD8 T"        "FCGR3A+ Mono"
5 [9] "NK"           "Platelet"    

plotting-accessories

除了向绘图添加交互功能之外,Seurat还提供了用于操作和组合绘图的新辅助功能。

1# LabelClusters and LabelPoints will label clusters (a coloring variable) or individual points
2# on a ggplot2-based scatter plot
3plot <- DimPlot(pbmc, reduction = "pca") + NoLegend()
4LabelClusters(plot = plot, id = "ident")

1# Both functions support `repel`, which will intelligently stagger labels and draw connecting
2# lines from the labels to the points or clusters
3LabelPoints(plot = plot, points = TopCells(object = pbmc[["pca"]]), repel = TRUE)

1# Plotting multiple plots at once is easy with CombinePlots
2plot1 <- DimPlot(pbmc)
3plot2 <- FeatureScatter(pbmc, feature1 = "LYZ", feature2 = "CCL5")
4# CombinePlots takes a list of ggplot2-based plots
5CombinePlots(plots = list(plot1, plot2))

1# CombinePlots can also easily remove the legend from the plots by passing `legend = 'none'`;
2# legends can also be combined with `legend = 'right'`
3CombinePlots(plots = list(plot1, plot2), legend = "none")

1# CombinePlots used cowplot:plot_grid under the hood, and will pass on additional arguments to
2# cowplot::plot_grid

(0)

相关推荐

  • 单细胞Marker基因可示化包Nebulosa

    与传统的转录组测序相比,单细胞测序技术噪声很大,使得单细胞转录组数据包含大量的dropout事件(导致基因表达量为0或接近0),即使是一些标记(Marker)基因也有可能表达量很低.当在使用其对聚类的 ...

  • Seurat学习与使用(一)

    简介Seurat是一个r包,被设计用于单细胞rna-seq数据的细胞质控和分析.Seurat旨在使用户能够识别和解释单细胞转录组数据中的异质性来源,同时提供整合不同类型的单细胞数据的函数.目前Seur ...

  • 单细胞工具箱|Seurat官网标准流程

    学习单细胞转录组肯定先来一遍Seurat官网的标准流程. 数据来源于Peripheral Blood Mononuclear Cells (PBMC),共2700个单细胞, Illumina Next ...

  • sc-RAN-seq 数据分析||Seurat新版教程:整合分析

    如果只是做单个样本的sc-RNA-seq数据分析,并不能体会到Seurat的强大,因为Seurat天生为整合而生. 本教程展示的是两个pbmc数据(受刺激组和对照组)整合分析策略,执行整合分析,以便识 ...

  • Seurat新版教程:分析空间转录组数据(上)

    男, 一个长大了才会遇到的帅哥, 稳健,潇洒,大方,靠谱. 一段生信缘,一棵技能树, 一枚大型测序工厂的螺丝钉, 一个随机森林中提灯觅食的津门旅客. 1思考题: 2 3+ 如何将空间数据与表达数据关联 ...

  • Seurat新版教程:分析空间转录组数据(下)

    男, 一个长大了才会遇到的帅哥, 稳健,潇洒,大方,靠谱. 一段生信缘,一棵技能树, 一枚大型测序工厂的螺丝钉, 一个随机森林中提灯觅食的津门旅客. 回顾 Seurat新版教程:分析空间转录组数据(上 ...

  • EndNote X9新版教程——中科大罗昭锋教授主讲

    EndNote X9新版教程——中科大罗昭锋教授主讲

  • 小米平板2 Lineage+Win10 双系统刷机教程v3.0

    小米平板2对安卓和 Win10 系统的兼容特性,使得它可以 Lineage+Win10 双系统并存,并因此深得用户喜爱.但它的双系统切换却非常不方便,成为一个痛点.本文的优化切换功能可以很好地解决这个 ...

  • 小米平板2 RR+Win10 双系统刷机教程v3.0

    小米平板2对安卓和 Win10 系统的兼容特性,使得它可以 ResurrectionRemix+Win10 双系统并存,并因此深得用户喜爱.但它的双系统切换却非常不方便,成为一个痛点.本文的优化切换功 ...

  • 小米平板2 Remix+Win10 双系统刷机教程v3.0

    小米平板2对安卓和 Win10 系统的兼容特性,使得它可以 Remix+Win10 双系统并存,并因此深得用户喜爱.但它的双系统切换却非常不方便,成为一个痛点.本文的优化切换功能可以很好地解决这个问题 ...

  • 谷歌再放大招!推出新版安卓12系统:华为鸿蒙OS2.0系统惨遭截胡

    [4月20日讯]导语,在近日,有媒体获得了一个尚未发布的最新安卓12系统构建版本,从曝光的Android 12系统的用户界面设计.交互功能.系统.续航等优化,都会给用户带来全新的体验,据透露,这次安卓 ...

  • 【商业教程】 cinema4D终极学习系统2.0第六卷 建模

    --  微资讯 · 微课程  -- 利用零碎时间,走上超神之路! 课程介绍 第六卷包含了cinema4D各种建模基础,包括各种各样的流程.本卷中所有章节都是基于项目包括 骷髅头,科幻飞船室内建模,香水 ...