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

计算各个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))

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。