計算各個cluster的細胞數(shù);
table(Idents(pbmc))
定義對應(yīng)每個cluster對應(yīng)的細胞類型,也可將ident改為相應(yīng)的細胞類型,計算每個細胞類型的細胞數(shù)
計算每個樣本的細胞數(shù)
table(pbmc$sampleID)
table(Seuratobject$slotname)
table(Idents(Seuratobject),Seuratobject$slotname)
$slotname可根據(jù)研究具體分組對每個樣本自行定義
計算細胞比例
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))