默认情况下,ggplot绘图细胞排序按照字符顺序排序,这里的mono细胞我想放在一起,该怎么做呢? 下面给出示例代码:
#气泡热图
marker <- c("IL7R", "CCR7", "CD14", "LYZ", "S100A4", "MS4A1" ,"CD8A", "FCGR3A", "MS4A7" ,
"GNLY", "NKG7", "FCER1A" ,"CST3" ,"PPBP" )
#设置自己喜欢的细胞排布顺序
celltype_order<-c("CD14+ Mono", "FCGR3A+ Mono", "CD4+ Naive T", "CD4+ Memory T" ,"CD8+ T" , "B", "NK", "T activated", "Platelet", "pDC", "mDC")
#设置需要显示的细胞类型注释为有序因子,并赋值给obj的ident
mycelltype=factor(obj$mycelltype,levels = celltype_order,ordered = T)
Idents(obj)<-mycelltype #绘图
DotPlot(obj, features = marker)+coord_flip()+
theme_bw()+
theme(panel.grid = element_blank(), axis.text.x=element_text(hjust = 1,vjust=1,angle = 45))+
labs(x=NULL,y=NULL)+guides(size=guide_legend(order=3))+
scale_color_gradientn(values = seq(0,1,0.2),colours = rev( brewer.pal(11,"RdYlBu"))) #改变一下颜色
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!