Seurat4.0系列教程7:数据可视化方法

我们将使用之前从 2,700个 PBMC 教程中计算的 Seurat 对象在 演示可视化技术。您可以从这里[1]下载此数据集

SeuratData::InstallData("pbmc3k")
library(Seurat)
library(SeuratData)
library(ggplot2)
library(patchwork)
data("pbmc3k.final")
pbmc3k.final$groups <- sample(c("group1", "group2"), size = ncol(pbmc3k.final), replace = TRUE)
features <- c("LYZ", "CCL5", "IL32", "PTPRCAP", "FCGR3A", "PF4")
pbmc3k.final

## An object of class Seurat 
## 13714 features across 2638 samples within 1 assay 
## Active assay: RNA (13714 features, 2000 variable features)
##  2 dimensional reductions calculated: pca, umap

marker基因可视化的5种方法

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

# Violin plot - Visualize single cell expression distributions in each cluster
VlnPlot(pbmc3k.final, features = features)

# Feature plot - visualize feature expression in low-dimensional space
FeaturePlot(pbmc3k.final, features = features)

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

# Single cell heatmap of feature expression
DoHeatmap(subset(pbmc3k.final, downsample = 100), features = features, size = 3)

FeaturePlot新增功能

# Plot a legend to map colors to expression levels
FeaturePlot(pbmc3k.final, features = "MS4A1")

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

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

# Visualize co-expression of two features simultaneously
FeaturePlot(pbmc3k.final, features = c("MS4A1", "CD79A"), blend = TRUE)

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

FeaturePlot()可视化功能更新和扩展

除了更改之外,其他几个绘图功能也已更新和扩展,具有新功能,并接管了现已废弃的函数的功能

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

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

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

pbmc3k.final.no.umap <- pbmc3k.final
pbmc3k.final.no.umap[["umap"]] <- NULL
DimPlot(pbmc3k.final.no.umap) + RotatedAxis()

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

将主题应用于绘图

Seurat所有绘图功能默认情况下返回基于 ggplot2 的绘图,允许人们像任何其他基于 ggplot2 的绘图一样轻松调整绘图。

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

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

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

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

交互式绘图功能

Seurat利用 R 的绘图库创建交互式绘图。此交互式绘图功能适用于任何基于 ggplot2 的散点图。要使用,只需制作基于 ggplot2 的散点图,并将生成的绘图传递给绘图函数geom_pointDimPlot() FeaturePlot() HoverLocator()

# Include additional data to display alongside cell names by passing in a data frame of
# information Works well when using FetchData
plot <- FeaturePlot(pbmc3k.final, features = "MS4A1")
HoverLocator(plot = plot, information = FetchData(pbmc3k.final, vars = c("ident", "PC_1", "nFeature_RNA")))

Seurat 提供的另一个交互式功能是能够手动选择cell以供进一步研究。我们发现,这对于小集群特别有用。现在,您可以通过创建基于 ggplot2 的散点图(例如使用或传递返回的绘图)来选择这些细胞。将返回带有所选点名称的向量,以便您可以将它们设置为新的身份并执行差异分析。例如,让我们假设 DCs 与聚类中的单核细胞合并,但我们想根据它们在 tSNE 绘图中的位置来了解它们的独特之处。

pbmc3k.final <- RenameIdents(pbmc3k.final, DC = "CD14+ Mono")
plot <- DimPlot(pbmc3k.final, reduction = "umap")
select.cells <- CellSelector(plot = plot)

然后,我们可以改变这些细胞的身份,把它们变成小群。

head(select.cells)

## [1] "AAGATTACCGCCTT" "AAGCCATGAACTGC" "AATTACGAATTCCT" "ACCCGTTGCTTCTA"
## [5] "ACGAGGGACAGGAG" "ACGTGATGCCATGA"
Idents(pbmc3k.final, cells = select.cells) <- "NewCells"

# Now, we find markers that are specific to the new cells, and find clear DC markers
newcells.markers <- FindMarkers(pbmc3k.final, ident.1 = "NewCells", ident.2 = "CD14+ Mono", min.diff.pct = 0.3, 
    only.pos = TRUE)
head(newcells.markers)
##                 p_val avg_log2FC pct.1 pct.2    p_val_adj
## FCER1A   3.239004e-69  3.7008561 0.800 0.017 4.441970e-65
## SERPINF1 7.761413e-36  1.5737896 0.457 0.013 1.064400e-31
## HLA-DQB2 1.721094e-34  0.9685974 0.429 0.010 2.360309e-30
## CD1C     2.304106e-33  1.7785158 0.514 0.025 3.159851e-29
## ENHO     5.099765e-32  1.3734708 0.400 0.010 6.993818e-28
## ITM2C    4.299994e-29  1.5590007 0.371 0.010 5.897012e-25

绘图配件

随着新功能为绘图添加交互式功能,Seurat 还提供新的配件功能来操纵和组合图片。

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

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

以前通过CombinePlot()功能绘制多个图。我们弃用此功能,转而支持patchwork拼图系统。下面是一个简短的演示,但请参阅此处[2]的拼图包网站,了解更多详细信息和示例。

plot1 <- DimPlot(pbmc3k.final)
plot2 <- FeatureScatter(pbmc3k.final, feature1 = "LYZ", feature2 = "CCL5")
# Combine two plots
plot1 + plot2

# Remove the legend from all plots
(plot1 + plot2) & NoLegend()

文中链接

[1]

这里: https://github.com/satijalab/seurat-data

[2]

此处: https://patchwork.data-imaginist.com/

(0)

相关推荐

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

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

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

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

  • Seurat学习与使用(一)

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

  • Seurat4.0系列教程:大数据集整合的方法

    对于非常大的数据集,标准工作流程可能计算成本高得令人望而却步.在此工作流程中,我们可采用如下两种方法提高效率和运行时间: Reciprocal PCA(RPCA) 基于参考的整合 主要的效率改进是使用 ...

  • Seurat4.0系列教程13:使用RPCA快速整合数据

    这是一个稍微修改的工作流程,用于整合 scRNA-seq 数据集.不再使用("CCA") 来识别锚点,而是使用 Reciprocal PCA("RPCA").在 ...

  • Seurat4.0系列教程14:整合scRNA-seq and scATAC-seq数据

    单细胞转录学改变了我们描述细胞状态的能力,但深入的生物学解释需要的不仅仅是分群.随着测量不同细胞模式的新方法的出现,一个关键的分析挑战是整合这些数据集,以更好地了解细胞身份和功能.例如,用户可以在同一 ...

  • Seurat4.0系列教程22:空间转录组的分析、可视化与整合

    Seurat4.0系列教程告一段落,但这决不是终点.这个系列教程只是给大家打开一扇窗,知道Seurat4.0有这些功能可用,少走弯路,起到一个抛砖引玉的作用,后续还要自己深入研究.不要像我当初入门单细 ...

  • Seurat4.0系列教程1:标准流程

    时代的洪流奔涌而至,单细胞技术也从旧时王谢堂前燕,飞入寻常百姓家.雪崩的时候,没有一片雪花是无辜的,你我也从素不相识,到被一起卷入单细胞天地.R语言和Seurat已以势如破竹之势进入4.0时代,天问一 ...

  • Seurat4.0系列教程3:合并数据集

    在此,我们将合并两个 10X PBMC 数据集:一个包含 4K 细胞,一个包含 8K 细胞.数据集可以在这里[1]找到. 首先,我们在数据中读入并创建两个Seurat对象. library(Seura ...

  • Seurat4.0系列教程4:整合分析

    scRNA-seq整合简介 对两个或两个以上单细胞数据集的整合分析提出了独特的挑战.特别是,在标准工作流下,识别存在于多个数据集中的基因可能存在问题.Seurat v4 包括一组方法,以匹配(或&qu ...

  • Seurat4.0系列教程5:交互技巧

    此文演示了一些与 Seurat 对象交互的功能.为了演示,我们将使用在第一个教程中创建的 2,700 个 PBMC 对象.为了模拟我们有两个复制的情景,我们将随机分配每个集群中一半的细胞自" ...

  • Seurat4.0系列教程6:常用命令

    Seurat 标准流程 标准 Seurat 工作流采用原始的单细胞表达数据,旨在数据中查找clusters.此过程包括数据标准化和高变基因选择.数据归一化.高变基因的PCA.共享近邻图形的构建以及使用 ...