最近看一篇文章的时候,发现文章的作者很厉害,写了一个用于单细胞转录组和Bulk RNA的可视化R包---dittoSeq。如果你对於seurat的可视化看腻了,这个R包是一个不错的选择。当然了,我还是那句话,够用就行了,****之所以要介绍这个包,主要是里面几个函数非常有用****!!!能够解决几个头疼的问题。
参考文献:
R包地址:https://github.com/dtm2451/dittoSeq。具体有用的参数我已经探索好了,详细注释代码已上传群文件!其他参数感兴趣的可自行探索!
首先加载R包并做一个小提琴图,风格挺好看的。
####安装R包,加载数据
BiocManager::install("dittoSeq")
library(dittoSeq)
library(dplyr)
mouse_data <- readRDS("D:/KS科研分享与服务公众号文章/mouse_data.rds")
####基因表达小提琴图
#theme主题的修饰和ggplot一样
dittoPlot(mouse_data,
"S100a8",
group.by = "orig.ident",
plots=c("vlnplot","boxplot"),
boxplot.fill=F,
boxplot.color='white',
color.panel = dittoColors(),
colors = c(1,3),
theme = theme(axis.text = element_text(size = 12, color = 'black'),
axis.line = element_line(size = 1),
axis.title.y = element_text(size = 15, color = 'black'),
plot.title = element_text(size=15,hjust=0.5, color = 'black')),
ylab = 'Expression',
y.breaks = seq(0,8,1),
xlab = '',
x.labels = c("Female","Male"),
x.labels.rotate =F,
max=8,
min=4,
main = "S100a8",
legend.show = F)
看一下UMAP图,可以置信区间:
####UMAP图---seurat中的dimplot
dittoDimPlot(mouse_data,
var = 'ident',
size = 2,
# split.by='orig.ident',
do.ellipse =T,
main = '',
theme=theme(axis.text = element_text(size = 12, color = 'black'),
axis.line = element_line(size = 1),
axis.title = element_text(size = 15, color = 'black')),
show.axes.numbers=T,
do.label=T,
labels.size = 4,
# add.trajectory.lineages=T,
# add.trajectory.curves=T, #有轨迹分析的话可以添加轨迹
legend.show=F)
更为重要的是,很多时候,我们做基因表达的时候,UMAP图标记,发现有些有表达的点被覆盖了,导致感觉表达不高,这里完美解决!
####UMAP图---seurat中的Featureplot
p1 <- dittoDimPlot(mouse_data,
var = 'Il1b',
size = 2,
theme = theme_classic(),
min.color = "lightgrey",
max.color = "blue",
main = "dittoSeq plot",
order = "increasing")#这个函数的优势
p2 <- FeaturePlot(mouse_data, features = 'Il1b', pt.size = 2)+
ggtitle('Seurat plot')
p1|p2
第二个优势,我们在seurat中查看细胞比例柱状图的时候,需要先进行麻烦的细胞比例计算,然后用ggplot作图,这里可以直接作图!
####单细胞比例图
p3 <- dittoBarPlot(mouse_data, "celltype", group.by = "orig.ident",main = '')
p4 <- dittoBarPlot(mouse_data, "orig.ident", group.by = "celltype",main = '')
p3|p4
最后一个我认为比较好的,就是热图,可以进行多重注释,很简单,而且出图快,也不会有bug,值得拥有!
marker <- FindAllMarkers(mouse_data,
min.pct = 0.25,
logfc.threshold = 0.25,
only.pos = T)
top_gene = marker %>%
group_by(cluster) %>%
top_n(n = 5, wt = avg_log2FC)
####
p5 <- dittoHeatmap(mouse_data, genes = top_gene$gene,
annot.by = c("celltype",
"SingleCellNet_Xie",
"orig.ident"),
scaled.to.max = F,
treeheight_row = 10,
heatmap.colors = colorRampPalette(c('#1A5592','white',"#B83D3D"))(50),
show_rownames=F,
highlight.features = c( "Ltf","Camp","Ngp",
"Il1b","Fgl2","Itga4","Csf3r",
"Ngp","Lcn2","Camp"))
好了,这些就是我认为比较好的地方了,其他的感兴趣的可自行探索。我想这个包结合自己的分析,在可视化上面相辅相成,有很大的促进。觉得分享有用的点个赞再走呗!更多精彩内容请至我的公众号---KS科研分享与服务