本文是参考学习单细胞转录组基础分析八:可视化工具总结的学习笔记。可能根据学习情况有所改动。
Seurat自带一些优秀的可视化工具,之前的分析内容陆续展示过一些,本节内容将总结这些可视化函数的使用。
RidgePlot山脊图
library(Seurat)
VlnPlot小提琴图
p1 = VlnPlot(scRNA, features = "nCount_RNA", pt.size = 0)
FeaturePlot特征图
p1 <- FeaturePlot(scRNA,features = "CD8A", reduction = 'umap')
DotPlot点图
genelist = c('LYZ','CD79A','CD8A','CD8B','GZMB','FCGR3A')
DoHeatmap热图
genelist = read.csv("cell_identify/top10_diff_genes_wilcox.csv")
FeatureScatter散点图
p1 <- FeatureScatter(scRNA, feature1 = 'PC_1', feature2 = 'PC_2')
DimPlot降维图
p1 <- DimPlot(scRNA, reduction = 'tsne', group.by = "celltype", label=T)
> library(Seurat)
> library(tidyverse)
> library(patchwork)
> rm(list=ls())
> dir.create("visual")
> scRNA <- readRDS("scRNA4.rds")
> p1 = RidgePlot(scRNA, features = "FCN1")
> p2 = RidgePlot(scRNA, features = "PC_2")
> plotc = p1/p2 + plot_layout(guides = 'collect')
> p1
Picking joint bandwidth of 0.0543
> p2
Picking joint bandwidth of 0.439
> plotc
Picking joint bandwidth of 0.0543
Picking joint bandwidth of 0.439
> ggsave('visual/ridgeplot_eg.png', plotc, width = 8,height = 8)
Picking joint bandwidth of 0.0543
Picking joint bandwidth of 0.439
> p1 = VlnPlot(scRNA, features = "nCount_RNA", pt.size = 0)
> p2 = VlnPlot(scRNA, features = "CD8A", pt.size = 0)
> plotc = p1/p2 + plot_layout(guides = 'collect')
> p1
> p2
> plotc
> ggsave('visual/vlnplot_eg.png', plotc, width = 8,height = 8)
> p1 <- FeaturePlot(scRNA,features = "CD8A", reduction = 'umap')
> p2 <- FeaturePlot(scRNA,features = "CD79A", reduction = 'umap')
> plotc = p1|p2
> p1
> p2
> plotc
> ggsave('visual/featureplot_eg.png', plotc, width = 10, height = 4)
> genelist = c('LYZ','CD79A','CD8A','CD8B','GZMB','FCGR3A')
> p = DotPlot(scRNA, features = genelist)
> ggsave('visual/dotplot_eg.png', p, width = 7, height = 5)
> p
> 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")
Warning message:
In DoHeatmap(scRNA, features = genelist, group.by = "seurat_clusters") :
The following features were omitted as they were not found in the scale.data slot for the RNA assay: PIK3IP1, LDHB
> p
> ggsave('visual/heatmap_eg.png', p, width = 12, height = 9)
> p1 <- FeatureScatter(scRNA, feature1 = 'PC_1', feature2 = 'PC_2')
> p2 <- FeatureScatter(scRNA, feature1 = 'nCount_RNA', feature2 = 'nFeature_RNA')
> plotc = p1|p2
> p1
> p2
> plotc
> ggsave('visual/featurescatter_eg.png', plotc, width = 10, height = 4)
> 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)
> p1
> p2
> p3
> p4
> plotc
> ggsave('visual/dimplot_eg.png', plotc, width = 10, height = 8)
>
> # 图片