seurat自带了很多绘图,但是可以自定义风格比较有限。
使用其他数据包能够弥补自定义绘图的不足。
关键问题是如何合理地提取seurat object里的数据?
我的示例数据如下:
seurat object 命名为 scRNA。
scRNA已经经过QC、降维聚类、能够画出umap图了。
0.导入数据
library(Seurat)
library(ggplot2)
library(tidyr)
library(dplyr)
# 示例数据
scRNA <- readRDS("D:/R/single cell sequencing/scRNA_练习.rds")
table(scRNA$Group) #分组信息存在了Group里
1.提取数据
使用seurat自带的FetchData进行提取数据。注意!以下方式二选一,有所区别。方法一如果直接提取数据,画小提琴的时候会出现负值。使用方法二则不会。
interested_gene <- c("SOD2","PAEP") #这里面设置自己想要的基因名字
# 1. 提取基因表达数据
#使用FetchData直接提取,这和直接用seurat画图的数据是一样的
#方法一:直接提取
interested_gene <- c("SOD2","PAEP")
data_df <- Seurat::FetchData(scRNA,vars = interested_gene)
data_df <- as.data.frame(data_df)
#方法二:设置默认的数据对象,这样画出的没有负值
DefaultAssay(scRNA) <- "RNA"
interes