其他
单细胞转录组基础分析八:可视化工具总结
Seurat自带一些优秀的可视化工具,之前的分析内容陆续展示过一些,本节内容将总结这些可视化函数的使用。
RidgePlot山脊图
library(Seurat)
library(tidyverse)
library(patchwork)
rm(list=ls())
dir.create("visual")
scRNA <- readRDS("scRNA.rds")
p1 = RidgePlot(scRNA, features = "FCN1")
p2 = RidgePlot(scRNA, features = "PC_2")
plotc = p1/p2 + plot_layout(guides = 'collect')
ggsave('visual/ridgeplot_eg.png', plotc, width = 8,height = 8)
VlnPlot小提琴图
p1 = VlnPlot(scRNA, features = "nCount_RNA", pt.size = 0)
p2 = VlnPlot(scRNA, features = "CD8A", pt.size = 0)
plotc = p1/p2 + plot_layout(guides = 'collect')
ggsave('visual/vlnplot_eg.png', plotc, width = 8,height = 8)
FeaturePlot特征图
p1 <- FeaturePlot(scRNA,features = "CD8A", reduction = 'umap')
p2 <- FeaturePlot(scRNA,features = "CD79A", reduction = 'umap')
plotc = p1|p2
ggsave('visual/featureplot_eg.png', plotc, width = 10, height = 4)
DotPlot点图
genelist = c('LYZ','CD79A','CD8A','CD8B','GZMB','FCGR3A')
p = DotPlot(scRNA, features = genelist)
ggsave('visual/dotplot_eg.png', p, width = 7, height = 5)
DoHeatmap热图
genelist = read.csv("cell_identify/top10_diff_genes_wilcox.csv")
genelist <- pull(genelist, gene) %>% as.character
p = DoHeatmap(scRNA, features = genelist, group.by = "seurat_clusters")
ggsave('visual/heatmap_eg.png', p, width = 12, height = 9)
FeatureScatter散点图
p1 <- FeatureScatter(scRNA, feature1 = 'PC_1', feature2 = 'PC_2')
p2 <- FeatureScatter(scRNA, feature1 = 'nCount_RNA', feature2 = 'nFeature_RNA')
plotc = p1|p2
ggsave('visual/featurescatter_eg.png', plotc, width = 10, height = 4)
DimPlot降维图
p1 <- DimPlot(scRNA, reduction = 'tsne', group.by = "celltype", label=T)
p2 <- DimPlot(scRNA, reduction = 'umap', group.by = "Phase", label=T)
p3 <- DimPlot(scRNA, reduction = 'pca', group.by = "celltype", label=T)
p4 <- DimPlot(scRNA, reduction = 'umap', group.by = "seurat_clusters", label=T)
plotc = (p1|p2)/(p3|p4)
ggsave('visual/dimplot_eg.png', plotc, width = 10, height = 8)
获取帮助
本教程的目的在于把常用的单细胞分析流程串起来,适合有一定R语言基础的朋友参考。分析原理和代码我没有详细解释,官网有详细的教程和权威的解释,翻译好的中文教程也有多个版本,有兴趣的可以搜索一下。如果您学习本教程有一定困难,可以分享此篇文章到朋友圈,截图微信发给Kinesin(文末二维码),我会抽时间组群直播讲解单细胞数据分析的全过程。本专题所用的软件、数据、代码脚本和中间结果,我打包放在了百度云上,需要的朋友添加Kinesin微信索取。
往期回顾
下期内容我们将介绍scRNA的高级分析,包括多样本整合、转录因子分析、细胞通讯分析、基因集变异分析和更全面的基因集富集分析,敬请期待!