漂亮的单细胞多组火山图
漂亮的单细胞多组火山图
最近发现一篇超级棒且适合做教材的单细胞文章,16分呢。《Single-cell transcriptome analysis reveals the association between histone lactylation and cisplatin resistance in bladder cancer 》其中的fig1B很好的展示了每种细胞类型的marker基因
漂亮的单细胞多组火山图
最近发现一篇超级棒且适合做教材的单细胞文章,16分呢。
《Single-cell transcriptome analysis reveals the association between histone lactylation and cisplatin resistance in bladder cancer 》
其中的fig1B很好的展示了每种细胞类型的marker基因,把我迷住了,把它复现出来,可以用在每个单细胞数据呢!拿去用。
输入数据是已经做完细胞类型注释的seurat对象,除此之外啥也不要啦。纯代码的。
代码语言:javascript代码运行次数:0运行复制rm(list = ls())
library(Seurat)
library(dplyr)
library(patchwork)
library(ggplot2)
load( "sce.Rdata")
scRA = sce
scRA@meta.data$celltype = Idents(scRA)
ctys = levels(scRA)
ctys
代码语言:javascript代码运行次数:0运行复制## [1] "naive B" "CD8 T" "aive CD4 T" "plasma B" "CD14+ Mono"
## [6] "endothelial" "Fibroblasts" "K" "DC"
代码语言:javascript代码运行次数:0运行复制 <- FindAllMarkers(scRA, min.pct = 0.25,
= 0.25)
head()
代码语言:javascript代码运行次数:0运行复制## p_val avg_log2FC pct.1 pct.2 p_val_adj cluster gene
## CD79A 0.000000e+00 5.56611 0.915 0.060 0.000000e+00 naive B CD79A
## BAK1 0.000000e+00 6.778892 0.85 0.026 0.000000e+00 naive B BAK1
## MS4A1 0.000000e+00 5.677155 0.848 0.050 0.000000e+00 naive B MS4A1
## HLA-DRA 1.482079e-06 2.775984 0.994 0.6 .060197e-02 naive B HLA-DRA
## HLA-DQB1 7.4172e-295 2.622558 0.926 0.207 1.515921e-290 naive B HLA-DQB1
## HLA-DQA1 5.404715e-292 2.727477 0.865 0.18 1.115966e-287 naive B HLA-DQA1
代码语言:javascript代码运行次数:0运行复制colnames()[6] = "celltype"
k = $p_val_adj<0.05;table(k)
代码语言:javascript代码运行次数:0运行复制## k
## FALSE TRUE
## 960 8946
代码语言:javascript代码运行次数:0运行复制 = [k,]
#上下调
$label <- ifelse($avg_log2FC<0,"sigDown","sigUp")
topgene <- %>%
group_by(celltype) %>%
top_n(n = 10, wt = avg_log2FC) %>%
bind_rows(group_by(, celltype) %>%
top_n(n = 10, wt = -avg_log2FC))
head(topgene)
代码语言:javascript代码运行次数:0运行复制## # A tibble: 6 × 8
## # Groups: celltype [1]
## p_val avg_log2FC pct.1 pct.2 p_val_adj celltype gene label
## <dbl> <dbl> <dbl> <dbl> <dbl> <fct> <chr> <chr>
## 1 0 6.78 0.85 0.026 0 naive B BAK1 sigUp
## 2 .1e-250 6.98 0.498 0.011 6.47e-246 naive B LIC00926 sigUp
## 2.59e-207 6.02 0.42 0.01 5.4e-20 naive B CD24 sigUp
## 4 1.42e-204 6.90 0.411 0.008 2.92e-200 naive B LIC0297 sigUp
## 5 1.15e-196 7.1 0.40 0.01 2.8e-192 naive B IGHD sigUp
## 6 5.77e-166 7.47 0.5 0.006 1.19e-161 naive B PAX5 sigUp
代码语言:javascript代码运行次数:0运行复制#根据log2FC范围确定背景柱长度:
dfbar = %>%
group_by(celltype) %>%
summarise(low = round(min(avg_log2FC)-0.5),
up = round(max(avg_log2FC)+0.5))
#绘制背景柱和散点图:
p1 <- ggplot()+
geom_col(aes(x = celltype ,y = low),dfbar,
fill = "#dcdcdc",alpha = 0.6)+
geom_col(aes(x = celltype ,y = up),dfbar,
fill = "#dcdcdc",alpha = 0.6)+
geom_jitter(aes(x = celltype, y = avg_log2FC, color = label),,
width =0.4,size = 1)+
scale_color_manual(values = c("#0077c0","#c72d2e"))+
theme_classic()
p1
#X轴的块标签:
library(RColorBrewer)
mycol <- colorRampPalette(rev(brewer.pal(n = 7, name ="Set1")))(length(ctys))
p2 <- p1 +
geom_tile(aes(x = ctys,y = 0),
height = 0.5,fill = mycol, show.legend = F)+
geom_text(aes(x= ctys, y = 0, label = ctys),
size = ,fontface = "bold")
p2
library(ggrepel)
#给每种细胞类型的top基因加上标签,调整细节:
p <- p2 +
geom_text_repel(aes(x = celltype,y = avg_log2FC,label = gene),
topgene,size = )+
labs(x = "CellType",y = "Average log2FoldChange",
title = "Differential expression genes")+
theme(
= element_text(size = 14,color = "black",face = "bold"),
= element_text(size = 12,color = "black",face = "bold"),
axis.line.y = element_line(color = "black",linewidth = 0.8),
axis.line.x = element_blank(),
x = element_blank(),
x = element_blank(),
panel.grid = element_blank(),
legend.position = c(0.98,0.96),
legend.background = element_blank(),
= element_blank(),
legend.direction = "vertical",
legend.justification = c(1,0),
= element_text(size = 12)
)+
guides(color = guide_legend(override.aes = list(size = 4)))
p
和原图一般无二啦。
本文参与 腾讯云自媒体同步曝光计划,分享自。原始发表:2024-11-07,如有侵权请联系 cloudcommunity@tencent 删除elementlegendsize对象数据#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格
上传时间: 2025-07-26 16:30:50
推荐阅读
留言与评论(共有 18 条评论) |
本站网友 自体活细胞隆胸 | 29分钟前 发表 |
celltype [1] ## p_val avg_log2FC pct.1 pct.2 p_val_adj celltype gene label ## <dbl> <dbl> <dbl> <dbl> <dbl> <fct> <chr> <chr> ## 1 0 6.78 0.85 0.026 0 naive B BAK1 sigUp ## 2 .1e-250 6.98 0.498 0.011 6.47e-246 naive B LIC00926 sigUp ## 2.59e-207 6.02 0.42 0.01 5.4e-20 naive B CD24 sigUp ## 4 1.42e-204 6.90 0.411 0.008 2.92e-200 naive B LIC0297 sigUp ## 5 1.15e-196 7.1 0.40 0.01 2.8e-192 naive B IGHD sigUp ## 6 5.77e-166 7.47 0.5 0.006 1.19e-161 naive B PAX5 sigUp 代码语言:javascript代码运行次数:0运行复制#根据log2FC范围确定背景柱长度: dfbar = %>% group_by(celltype) %>% summarise(low = round(min(avg_log2FC)-0.5) | |
本站网友 mp3文件 | 29分钟前 发表 |
漂亮的单细胞多组火山图 最近发现一篇超级棒且适合做教材的单细胞文章 | |
本站网友 姓名与八字 | 20分钟前 发表 |
除此之外啥也不要啦 | |
本站网友 曹臻 | 23分钟前 发表 |
= 0.25) head() 代码语言:javascript代码运行次数:0运行复制## p_val avg_log2FC pct.1 pct.2 p_val_adj cluster gene ## CD79A 0.000000e+00 5.56611 0.915 0.060 0.000000e+00 naive B CD79A ## BAK1 0.000000e+00 6.778892 0.85 0.026 0.000000e+00 naive B BAK1 ## MS4A1 0.000000e+00 5.677155 0.848 0.050 0.000000e+00 naive B MS4A1 ## HLA-DRA 1.482079e-06 2.775984 0.994 0.6 .060197e-02 naive B HLA-DRA ## HLA-DQB1 7.4172e-295 2.622558 0.926 0.207 1.515921e-290 naive B HLA-DQB1 ## HLA-DQA1 5.404715e-292 2.727477 0.865 0.18 1.115966e-287 naive B HLA-DQA1 代码语言:javascript代码运行次数:0运行复制colnames()[6] = "celltype" k = $p_val_adj<0.05;table(k) 代码语言:javascript代码运行次数:0运行复制## k ## FALSE TRUE ## 960 8946 代码语言:javascript代码运行次数:0运行复制 = [k | |
本站网友 先天性髋关节脱位 | 11分钟前 发表 |
legend.justification = c(1 | |
本站网友 城西房产 | 2分钟前 发表 |
0.96) | |
本站网友 脑血管瘤 | 25分钟前 发表 |
face = "bold") | |
本站网友 草桥欣园 | 11分钟前 发表 |
axis.line.y = element_line(color = "black" | |
本站网友 好想日b | 23分钟前 发表 |
dfbar | |
本站网友 结业证 | 16分钟前 发表 |
dfbar | |
本站网友 深圳电影院 | 0秒前 发表 |
0) | |
本站网友 葫芦岛房地产网 | 6分钟前 发表 |
原始发表:2024-11-07 | |
本站网友 苦茶的作用 | 9分钟前 发表 |
axis.line.y = element_line(color = "black" | |
本站网友 智能微波炉 | 11分钟前 发表 |
fill = "#dcdcdc" | |
本站网友 格兰宝 | 1分钟前 发表 |
face = "bold") | |
本站网友 南头古城 | 19分钟前 发表 |
celltype [1] ## p_val avg_log2FC pct.1 pct.2 p_val_adj celltype gene label ## <dbl> <dbl> <dbl> <dbl> <dbl> <fct> <chr> <chr> ## 1 0 6.78 0.85 0.026 0 naive B BAK1 sigUp ## 2 .1e-250 6.98 0.498 0.011 6.47e-246 naive B LIC00926 sigUp ## 2.59e-207 6.02 0.42 0.01 5.4e-20 naive B CD24 sigUp ## 4 1.42e-204 6.90 0.411 0.008 2.92e-200 naive B LIC0297 sigUp ## 5 1.15e-196 7.1 0.40 0.01 2.8e-192 naive B IGHD sigUp ## 6 5.77e-166 7.47 0.5 0.006 1.19e-161 naive B PAX5 sigUp 代码语言:javascript代码运行次数:0运行复制#根据log2FC范围确定背景柱长度: dfbar = %>% group_by(celltype) %>% summarise(low = round(min(avg_log2FC)-0.5) | |
本站网友 牙齿美白秘方 | 26分钟前 发表 |
wt = -avg_log2FC)) head(topgene) 代码语言:javascript代码运行次数:0运行复制## # A tibble |