Seurat 中的数据可视化方法

本文[1]将使用从 2,700 PBMC 教程计算的 Seurat 对象来演示 Seurat 中的可视化技术。您可以从 SeuratData[2] 下载此数据集。

SeuratData::InstallData("pbmc3k")

library(Seurat)
library(SeuratData)
library(ggplot2)
library(patchwork)
pbmc3k.final <- LoadData("pbmc3k", type = "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)
##  3 layers present: data, counts, scale.data
##  2 dimensional reductions calculated: pca, umap

marker 特征表达的五种可视化

1. RidgePlot

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

2. VlnPlot

# Violin plot - Visualize single cell expression distributions in each cluster
VlnPlot(pbmc3k.final, features = features)
alt
# 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")
alt

3. FeaturePlot

# Feature plot - visualize feature expression in low-dimensional space
FeaturePlot(pbmc3k.final, features = features)
alt
# Plot a legend to map colors to expression levels
FeaturePlot(pbmc3k.final, features = "MS4A1")
alt
# Adjust the contrast in the plot
FeaturePlot(pbmc3k.final, features = "MS4A1", min.cutoff = 1, max.cutoff = 3)
alt
# 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")
alt
# Visualize co-expression of two features simultaneously
FeaturePlot(pbmc3k.final, features = c("MS4A1""CD79A"), blend = TRUE)
img
img
# Split visualization to view expression by groups (replaces FeatureHeatmap)
FeaturePlot(pbmc3k.final, features = c("MS4A1""CD79A"), split.by = "groups")
alt

4. DotPlot

# 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()
alt
# SplitDotPlotGG has been replaced with the `split.by` parameter for DotPlot
DotPlot(pbmc3k.final, features = features, split.by = "groups") + RotatedAxis()
alt

5. DoHeatmap

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

新绘图函数

DimPlot

# DimPlot replaces TSNEPlot, PCAPlot, etc. In addition, it will plot either 'umap', 'tsne', or
# 'pca' by default, in that order
DimPlot(pbmc3k.final)
alt
pbmc3k.final.no.umap <- pbmc3k.final
pbmc3k.final.no.umap[["umap"]] <- NULL
DimPlot(pbmc3k.final.no.umap) + RotatedAxis()
alt

DoHeatmap

# 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()
alt

将主题应用于绘图

使用 Seurat,所有绘图函数默认返回基于 ggplot2 的绘图,允许人们像任何其他基于 ggplot2 的绘图一样轻松捕获和操作绘图。

baseplot <- DimPlot(pbmc3k.final, reduction = "umap")
# Add custom labels and titles
baseplot + labs(title = "Clustering of 2,700 PBMCs")
alt
# Use community-created themes, overwriting the default Seurat-applied theme Install ggmin
# with remotes::install_github('sjessa/ggmin')
baseplot + ggmin::theme_powerpoint()
alt
# Seurat also provides several built-in themes, such as DarkTheme; for more details see
# ?SeuratTheme
baseplot + DarkTheme()
alt
# Chain themes together
baseplot + FontSize(x.title = 20, y.title = 20) + NoLegend()
alt

交互式绘图功能

Seurat 利用 R 的绘图库来创建交互式绘图。此交互式绘图功能适用于任何基于 ggplot2 的散点图(需要 geom_point 图层)。使用时,只需制作一个基于 ggplot2 的散点图(例如 DimPlot() 或 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")))
alt

Seurat 提供的另一个交互功能是能够手动选择细胞以进行进一步研究。我们发现这对于小簇特别有用,这些小簇并不总是使用无偏聚类来分离,但看起来却截然不同。现在,您可以通过创建基于 ggplot2 的散点图(例如使用 DimPlot() 或 FeaturePlot(),并将返回的图传递给 CellSelector() 来选择这些单元格。CellSelector() 将返回一个包含所选点名称的向量,这样您就可以将它们设置为新的身份类并执行微分表达式。

例如,假设 DC 在聚类中与单核细胞合并,但我们想根据它们在 tSNE 图中的位置来了解它们的独特之处。

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

绘图配件

除了为绘图添加交互功能的新函数之外,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")
alt
# 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)
alt

绘制多个图之前是通过CombinePlot() 函数实现的。我们不赞成使用此功能,转而使用拼凑系统。下面是一个简短的演示,但请参阅此处的 patchwork[3] 包网站以获取更多详细信息和示例。

plot1 <- DimPlot(pbmc3k.final)
# Create scatter plot with the Pearson correlation value as the title
plot2 <- FeatureScatter(pbmc3k.final, feature1 = "LYZ", feature2 = "CCL5")
# Combine two plots
plot1 + plot2
alt
# Remove the legend from all plots
(plot1 + plot2) & NoLegend()
alt
Reference
[1]

Source: https://satijalab.org/seurat/articles/visualization_vignette

[2]

Data: https://github.com/satijalab/seurat-data

[3]

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

本文由 mdnice 多平台发布

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/517861.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

基于逻辑回归实现乳腺癌预测(机械学习与大数据)

基于逻辑回归实现乳腺癌预测 将乳腺癌数据集拆分成训练集和测试集&#xff0c;搭建一个逻辑回归模型&#xff0c;对训练集进行训练&#xff0c;然后分别对训练集和测试集进行预测。输出以下结果&#xff1a; 该模型在训练集上的准确率&#xff0c;在测试集上的准确率、召回率和…

python 爬虫爬取知乎LOL图片(亲测)

获取信息 访问url后按f12调试 点击network 定位图片信息&#xff1a; 可以看到&#xff0c;每个图片的名字和下载地址在标红处&#xff0c;示例如下&#xff1a; data-actualsrc“https://pic4.zhimg.com/v2-1681ff26afbd5f92aa5790b4dee6a63f_b.jpg” 现在就是requests访问…

UE4 Niagara 关卡1.4官方案例解析

sprites can face the camera&#xff0c;or they can face any arbitrary vector&#xff0c;in this case the vector between the center of the system and the particle itself&#xff08;粒子可以面对摄影机&#xff0c;也可以面对任意向量&#xff0c;在这个实例中的向…

Excel中怎么求排名

使用Rank函数 1.在需要显示排名的单元格内&#xff0c;输入“RANK&#xff08;数值&#xff0c;数值列表&#xff0c;排序方式&#xff09;” 2.将“数值”替换为需要计算排名的单元格的地址&#xff0c;例如E2单元格。 3.将“数值列表”替换为排名的数值范围&#xff0c;例…

光纤常用的七种模块,多模与单模光纤区别有哪些?

中午好&#xff0c;我的网工朋友。 在当今的光纤通信中&#xff0c;光纤被广泛地应用在网络、电视、电话等各种通信系统中。 有网工小白经常会问到关于光纤的接口有哪些?如何使用&#xff1f; 多模光纤与单模光纤的传输距离、传输带宽、使用波长等问题一直让很多网工人疑惑…

【HTML】HTML基础7.1(无序列表)

目录 标签 属性 效果 注意 标签 <ul> <li>列表里要装的东西</li> <li>列表里要装的东西</li> <li>列表里要装的东西</li> </ul> 属性 type&#xff1a; circle空心圆disc实心圆square方框 效果 circle空心圆效果…

【论文阅读】MC:用于语义图像分割的深度卷积网络弱监督和半监督学习

【论文阅读】MC&#xff1a;用于语义图像分割的深度卷积网络弱监督和半监督学习 文章目录 【论文阅读】MC&#xff1a;用于语义图像分割的深度卷积网络弱监督和半监督学习一、介绍二、联系工作三、方法四、实验结果 Weakly- and Semi-Supervised Learning of a Deep Convolutio…

OpenAI 大声朗读出来

每周跟踪AI热点新闻动向和震撼发展 想要探索生成式人工智能的前沿进展吗&#xff1f;订阅我们的简报&#xff0c;深入解析最新的技术突破、实际应用案例和未来的趋势。与全球数同行一同&#xff0c;从行业内部的深度分析和实用指南中受益。不要错过这个机会&#xff0c;成为AI领…

react中tab选项卡切换

react中tab选项卡切换&#xff0c;直接上代码&#xff0c;简单易懂 jsx代码 /* eslint-disable react-hooks/exhaustive-deps */ import React, { useEffect, useState } from "react"; import DocumentTitle from react-document-title import styles from ./…

程控水冷阻性负载的原理与应用

程控水冷阻性负载是一种利用计算机程序控制水冷系统对阻性负载进行冷却的技术。它主要应用于电力电子设备、电力系统、新能源等领域&#xff0c;以提高设备的稳定性和可靠性&#xff0c;降低能耗&#xff0c;延长设备寿命。 程控水冷阻性负载的原理&#xff1a; 1. 阻性负载&a…

f5——>字符串三角

暴力破解&#xff0c;双层循环&#xff0c;注意复制到新列表用append&#xff0c;这样更不容易出错 格式还是“”.join(str)

MQTT控制报文介绍(2)

一、CONNECT – 连接 服务端 客户端到服务端的网络连接建立后&#xff0c;客户端发送给服务端的第一个报文 必须是 CONNECT 报文。在一个网络连接上&#xff0c;客户端只能发送一次 CONNECT 报文。服务端 必须将客户端发送的第二个 CONNECT报文当作协议违规处理并断开客户端的…