美文网首页单细胞测序专题集合
单细胞seurat学习笔记计算各个cluster的细胞数绘制堆叠

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

作者: 麒麟991 | 来源:发表于2019-10-26 15:25 被阅读0次

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

    相关文章

      网友评论

        本文标题:单细胞seurat学习笔记计算各个cluster的细胞数绘制堆叠

        本文链接:https://www.haomeiwen.com/subject/lazyvctx.html