单细胞测序专题集合

单细胞seurat学习笔记计算各个cluster的细胞数绘制堆叠

2019-10-26  本文已影响0人  麒麟991

计算各个cluster的细胞数;

table(Idents(pbmc))

定义对应每个cluster对应的细胞类型,也可将ident改为相应的细胞类型,计算每个细胞类型的细胞数

计算每个样本的细胞数

table(pbmc$sampleID)

table(Seuratobject$slotname)

table(Idents(Seuratobject),Seuratobject$slotname)

$slotname可根据研究具体分组对每个样本自行定义

计算细胞比例

prop.table(table(Idents(pbmc)))

prop.table(table(Idents(Seuratobject),Seuratobject$slotname))

绘制堆叠条形图

cell.prop<-as.data.frame(prop.table(table(Idents(pbmc), pbmc$patient)))

colname(cell.prop)<-c(''cluster","patient","proportion")

ggplot(cell.prop,aes(patient,proportion,fill=cluster))+

geom_bar(stat="identity",position="fill")+

ggtitle("")+

theme_bw()+

theme(axis.ticks.length=unit(0.5,'cm'))+

guides(fill=guide_legend(title=NULL))

上一篇 下一篇

猜你喜欢

热点阅读