Seurat:計算cluster的細胞比例和繪制堆疊條形圖

計算各個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))

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容