前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >展示你的特征基因:带"辣椒粉"的markers基因umap图

展示你的特征基因:带"辣椒粉"的markers基因umap图

作者头像
生信技能树
发布2025-03-11 21:26:26
发布2025-03-11 21:26:26
10500
代码可运行
举报
文章被收录于专栏:生信技能树生信技能树
运行总次数:0
代码可运行

今天来看看如何展示你的特征基因,这个需求在单细胞分析中非常常见。图来自文献《The aged tumor microenvironment limits T cell control of cancer》,于2024年6月25日发表在Nat Immunol杂志上(IF27.8)。如下:

图注:

Fig. 4. Cell-extrinsic signals from the aged TME drive the TTAD subset state, which is distinct from CD8+ T cell exhaustion. j, scRNA-seq UMAP projection of 7,242 tumor-infiltrating CD8+ T cells from human pan-cancer aggregated tumor biopsies (n = 57) colored by cluster.

文章中还有很多其他的这种UMAP展示,换一个色系的:

示例数据

使用的数据还是自 GSE128531 数据注释后的seurat对象,你自己用的时候可以使用任何一个经过了注释后的seurat对象。或者在这里下载链接: https://pan.baidu.com/s/16ZzlZBp2_grEXEpX-ggPnw?pwd=2jdp 提取码: 2jdp

代码语言:javascript
代码运行次数:0
运行
复制
###
### Create: Jianming Zeng
### Date:  2023-12-31  
### Email: jmzeng1314@163.com
### Blog: http://www.bio-info-trainee.com/
### Forum:  http://www.biotrainee.com/thread-1376-1-1.html
### CAFS/SUSTC/Eli Lilly/University of Macau
### Update Log: 2023-12-31   First version 
### Update Log: 2024-12-09   by juan zhang (492482942@qq.com)
### 

rm(list=ls())
library(COSG)
library(harmony)
library(ggsci)
library(dplyr) 
library(future)
library(Seurat)
library(clustree)
library(cowplot)
library(data.table)
library(dplyr)
library(ggplot2)
library(patchwork)
library(stringr)
library(qs)

# 导入数据
sce.all.int <- readRDS('2-harmony/sce.all_int.rds')
head(sce.all.int@meta.data)
load("phe.Rdata")
head(phe)
sce.all.int <- AddMetaData(sce.all.int, metadata = phe)

Idents(sce.all.int) <- "celltype"

确定展示的特征基因

我这里挑了12个基因,为每种细胞的已知marker基因,如下:

  • macrophages: AIF1
  • keratinocytes: KRT1
  • T lymphocytes: CD3D
  • fibroblasts: COL1A1
  • endothelial cells: VWF
  • mast cells: TPSAB1
  • secretory (glandular) cells: SCGB1B2P
  • pericytes: RGS5
  • melanocytes: PMEL
  • B cells: MS4A1
  • smooth muscle cells: DES
  • dendritic cells: CD1C

先绘制一个基因看看

使用 scCustomize 这个包:

代码语言:javascript
代码运行次数:0
运行
复制
################## umap4:scCustomize
library(viridis)
library(Seurat)
library(scCustomize)

# 绘图
p <- FeaturePlot_scCustom(seurat_object = sce.all.int, features = "CD3E", order = T,pt.size = 0.4) + 
  scale_color_gradient(low = "grey", high = "#f32a1f")  + # 更改填充颜色 
  theme_void() +  # 使用空白主题
  theme( plot.title = element_text(hjust = 0.5, size = 16, face = "italic"), # 标题居中
         legend.position = "none", # 去除图例
         panel.border = element_blank(),
         panel.grid.major = element_blank(),
         panel.grid.minor = element_blank(),
         panel.background = element_blank(),
         plot.background = element_blank())
p

结果如下:

多个基因绘制在一个面板

接下来将多个基因绘制在一个图中,这里总共有12个基因,可以选择4X3的排列方式,比较美观,拼图使用patchwork包:

代码语言:javascript
代码运行次数:0
运行
复制
# 确定特征基因
selected_genes <- list("macrophages"="AIF1",
                       "keratinocytes"="KRT1",
                       "T lymphocytes"="CD3D",
                       "fibroblasts"="COL1A1",
                       "endothelial cells"="VWF",
                       "mast cells"="TPSAB1",
                       "secretory (glandular) cells"="SCGB1B2P",
                       "pericytes"="RGS5",
                       "melanocytes"="PMEL",
                       "B cells"="MS4A1",
                       "smooth muscle cells"="DES",
                       "dendritic cells"="CD1C")
g <- unlist(selected_genes)
g

# 生成一个存储多个ggplot对象的list
p_merge <- list()

for(i in 1:length(g)) {
# 打印动态
print(g[i])
# 绘图
  p_merge[[i]] <- FeaturePlot_scCustom(seurat_object = sce.all.int, features = g[i], order = T,pt.size = 0.6) + 
    scale_color_gradient(low = "grey", high = "#f32a1f")  + # 更改填充颜色 
    theme_void() +  # 使用空白主题
    theme( plot.title = element_text(hjust = 0.5, size = 16, face = "bold"), # 标题居中
      legend.position = "none", # 去除图例
      panel.border = element_blank(),
      panel.grid.major = element_blank(),
      panel.grid.minor = element_blank(),
      panel.background = element_blank(),
      plot.background = element_blank())
}

# 拼图
library(patchwork)
# 有多少个基因,3行4咧
length(g)
# 使用 patchwork 的 wrap_plots() 函数组合图表
combined_plot <- wrap_plots(p_merge, ncol = 4)
combined_plot

# 保存
ggsave(filename = "Salt_UMAP.pdf", width = 11.5, height = 8, plot = combined_plot)
ggsave(filename = "Salt_UMAP.png", width = 11.5, height = 8, plot = combined_plot)

结果如下:

完美~

换一个色系

改一下:scale_color_gradient(low = "grey", high = "#f32a1f")

代码语言:javascript
代码运行次数:0
运行
复制
# 生成一个存储多个ggplot对象的list
p_merge <- list()

for(i in 1:length(g)) {
# 打印动态
print(g[i])
# 绘图
  p_merge[[i]] <- FeaturePlot_scCustom(seurat_object = sce.all.int, features = g[i], order = T,pt.size = 0.6) + 
    scale_color_gradient(low = "grey", high = "#44579a")  + # 更改填充颜色
    theme_void() +  # 使用空白主题
    theme( plot.title = element_text(hjust = 0.5, size = 16, face = "bold"), # 标题居中
      legend.position = "none", # 去除图例
      panel.border = element_blank(),
      panel.grid.major = element_blank(),
      panel.grid.minor = element_blank(),
      panel.background = element_blank(),
      plot.background = element_blank())
}

# 拼图
library(patchwork)
# 有多少个基因,3行4咧
length(g)
# 使用 patchwork 的 wrap_plots() 函数组合图表
combined_plot <- wrap_plots(p_merge, ncol = 4)
combined_plot

# 保存
ggsave(filename = "Salt_UMAP.pdf", width = 11.5, height = 8, plot = combined_plot)
ggsave(filename = "Salt_UMAP.png", width = 11.5, height = 8, plot = combined_plot)
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2025-03-10,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 生信技能树 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 示例数据
  • 确定展示的特征基因
  • 先绘制一个基因看看
  • 多个基因绘制在一个面板
    • 完美~
  • 换一个色系
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档