输出细胞类群的marker并绘图

#====================================================鉴定不同定义细胞类群分子标记
MyMarker_celltype <- function(seurat_object,path_out){
marker_list <- list()
for (cell_type in unique(seurat_object@meta.data$cell_type)){
  cell_1 <- rownames(seurat_object@meta.data)[seurat_object@meta.data$cell_type == cell_type]
marker_list[[cell_type]] <- FindMarkers(seurat_object,ident.1=cell_1,only.pos=TRUE,assay="RNA")
}
write.xlsx(marker_list, file=paste(path_out,'all_cell_type_markers.xlsx',sep='/'), row.names=TRUE,overwrite=T)
saveRDS(marker_list,file=paste(path_out,"all_cell_type_markers.rds",sep="/"))
cell_type_marker_top <- unique(unlist(lapply(marker_list,function(x) {top <- rownames(x[order(x$avg_log2FC,decreasing=T),])[1:10]}))) #每个top10作为marker
plot_markers <- DotPlot(seurat_object , features = cell_type_marker_top,assay='RNA',group.by="cell_type" ) + coord_flip()
ggsave("dot_plot_cell_type_markers.png",plot_markers,path=path_out,width=10,height=15)
return(marker_list)
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容