手动绘制dimplot

手动绘制dimplot




#指定细胞类型顺序

#as.character(unique(obj$mycelltype))


cluster_order <- c("CD4+ Naive T","CD4+ Memory T","T activated", "CD14+ Mono" , "CD8+ T"  , "NK"    , "FCGR3A+ Mono", "B" ,           "pDC" ,         "mDC"  ,        "Platelet"  )


#提取坐标和注释数据

df <- tibble(

  UMAP_1 = as.data.frame(obj@reductions$umap@cell.embeddings)$umap_1,

  UMAP_2 = as.data.frame(obj@reductions$umap@cell.embeddings)$umap_2,

  cluster = factor(obj@meta.data$mycelltype,levels =cluster_order,ordered = T )) 


#获取细胞亚群Umap的中心点

df_center <- df %>%

  group_by(cluster) %>%

  summarise(x = median(UMAP_1), y = median(UMAP_2))


#ggplot散点图绘制

ggplot(df) +

  geom_point(size = 1,aes(UMAP_1, UMAP_2, color = cluster)) +

  geom_point(size = 5,

             data = df_center,

             mapping = aes(x, y),

             color="grey90",

             alpha = 0.8)+

  geom_text(data = df_center,

            mapping = aes(x, y, label = cluster),

            color='black')+

  scale_color_manual(values = color_palette)+

  theme_dr()+

  theme(panel.grid.major = element_blank(), 

        panel.grid.minor = element_blank(), 

        panel.background = element_blank())+

  NoLegend()




attachments-2026-04-SgeRGubr69d6198a2b95b.png

  • 发表于 10小时前
  • 阅读 ( 15 )
  • 分类:转录组

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
omicsgene
omicsgene

生物信息

767 篇文章

作家榜 »

  1. omicsgene 767 文章
  2. 安生水 371 文章
  3. Daitoue 167 文章
  4. 生物女学霸 120 文章
  5. xun 96 文章
  6. rzx 88 文章
  7. 红橙子 81 文章
  8. Ti Amo 78 文章