我想把右边的每一组都做成左边的图,左边是四个组整合在一起的,想把他们弄成四个饼状图
scRNA_annotations$celltype <- scRNA_annotations@active.ident
scRNA.b<-scRNA_annotations
unique(scRNA.b$orig.ident)
table(scRNA.b$celltype)
cellnum <- table(scRNA.b$celltype,scRNA.b$orig.ident)
cell.prop<-as.data.frame(prop.table(cellnum))
colnames(cell.prop)<-c("celltype","orig.ident","proportion")
p.bar <- ggplot(cell.prop,aes(orig.ident,proportion,fill=celltype))+
geom_bar(stat="identity",position="fill")+
scale_fill_manual(values=c("#E64B35FF","#4DBBD5FF","#00A087FF","#3C5488FF","#F39B7FFF","#8491B4FF","#91D1C2FF","#DC0000FF"))+#自定义fill的颜色
ggtitle("Cell proportion")+
theme_bw()+
theme(axis.title = element_text(size=20),axis.text.y= element_text(size=15),axis.text.x = element_text(size=15),plot.title=element_text(size=20),panel.border = element_rect(fill=NA,color="black", size=1, linetype="solid"),axis.ticks.length=unit(0.5,'cm'))+
guides(fill=guide_legend(title="Celltype"))
p.bar
我想把右边的每一组都做成左边的图,左边是四个组整合在一起的,想把他们弄成四个饼状图