trata de ser normal
1. Introducción
Un diagrama de gsea en un artículo de NC La ferroptosis inducida por neutrófilos promueve la necrosis tumoral en la progresión del glioblastoma :
artículo:
En la actualidad, la idea simple es hacer un rompecabezas , si no es suficiente, habrá algunos problemas, los resultados se muestran a continuación:
打赏我 5 个大洋
Amigos, pueden contactarme en privado al final del tweet y tomar una captura de pantalla, y compartiré la literatura, los datos de prueba y el código con ustedes.
2 datos de prueba
Cargue los datos de prueba, incluidos dos canales:
# 加载R包
library(ggplot2)
library(ggnewscale)
library(aplot)
# load data
df <- read.delim('c:/Users/admin/Desktop/test_data.txt',header = T)
# 查看内容
head(df,3)
NAME SYMBOL TITLE RANK.IN.GENE.LIST RANK.METRIC.SCORE RUNNING.ES CORE.ENRICHMENT
1 row_0 LDB3 na 173 0.2474102 0.02058329 Yes
2 row_1 GATA6 na 249 0.2274002 0.04379894 Yes
3 row_2 ABCC6 na 262 0.2252293 0.06997884 Yes
pathway
1 ANGINA_PECTORIS
2 ANGINA_PECTORIS
3 ANGINA_PECTORIS
3Dibuja el gráfico
Primero dibuja el gráfico de arriba:
# plot
up <- ggplot(df,aes(x = RANK.IN.GENE.LIST,y = RUNNING.ES,color = pathway)) +
# 0水平线
geom_hline(yintercept = 0,color = 'grey',size = 1) +
# 曲线图层
geom_line(show.legend = F,size = 1) +
# 颜色设置
scale_color_manual(values = c('#4E9F3D','#FF87CA')) +
theme_bw(base_size = 18) +
# 主题细节调整
theme(panel.grid = element_blank(),
axis.ticks.length = unit(0.25,'cm'),
panel.border = element_rect(size = 2),
axis.text.x = element_blank(),
axis.title.x = element_blank(),
axis.ticks.x = element_blank()) +
ylab('Enrichment score') +
# 添加文本注释
annotate(geom = 'text',x = 5500,y = 0.05,size = 6,
label = 'Negative role\n(P = 0.759, FDR = 0.764)') +
annotate(geom = 'text',x = 11000,y = 0.45,size = 6,
label = 'Positive role\n(P = 0.004, FDR = 0.007)') +
# 添加箭头注释
geom_segment(aes(x = 10000,xend = 11000,y = 0.05,yend = 0.1),show.legend = F,
arrow = arrow(length=unit(0.4,"cm"),type = 'open'),
color = 'black',size = 0.5) +
geom_segment(aes(x = 8000,xend = 7500,y = 0.4,yend = 0.35),show.legend = F,
arrow = arrow(length=unit(0.4,"cm"),type = 'open'),
color = 'black',size = 0.5)
up
4 Dibujar el diagrama de clasificación intermedia
Trace el gráfico de ordenación de genes en el medio:
# line
mid <- ggplot(df,aes(x = RANK.IN.GENE.LIST,y = pathway)) +
# 线图层
geom_vline(aes(xintercept = RANK.IN.GENE.LIST,
color = pathway),
show.legend = F,size = 0.5) +
# 颜色
scale_color_manual(values = c('#4E9F3D','#FF87CA')) +
theme_classic(base_size = 18) +
# 分面
facet_wrap(~pathway,ncol = 1) +
# 主题调整
theme(strip.background = element_blank(),
strip.text = element_blank(),
axis.ticks.length = unit(0.25,'cm'),
axis.text.x = element_blank(),
axis.title.x = element_blank(),
axis.line.x = element_blank(),
axis.ticks.x = element_blank(),
axis.line.y = element_line(color = 'white'),
axis.title.y = element_text(color = 'white'))
mid
5 Mapa de calor inferior
Finalmente, se dibuja el mapa de calor subyacente, pero no sé de qué color se llena el color, creo que puede ser la posición ordenada:
# heatmap
bot <- ggplot(te,aes(x = x,y = 1,fill = x)) +
# 条形图层
geom_col(width = 1,show.legend = F) +
# 颜色
scale_fill_gradient2(low = 'red',mid = 'white',high = 'blue',
midpoint = max(df$RANK.IN.GENE.LIST)/2) +
# 设置刻度标签
scale_x_continuous(breaks = seq(0,max(df$RANK.IN.GENE.LIST),3500),
labels = seq(0,max(df$RANK.IN.GENE.LIST),3500)/1000) +
theme_classic(base_size = 18) +
coord_cartesian(expand = 0) +
# 主题调整
theme(axis.ticks.y = element_blank(),
axis.text.y = element_blank(),
axis.title.y = element_blank(),
axis.line.y = element_blank(),
axis.line.x = element_blank(),
axis.ticks.length = unit(0.25,'cm')) +
# 轴标签
xlab('Ranked in ordered dataset\n(x1000)') +
labs(caption = c("MES", "PN")) +
# 添加注释
theme(plot.caption = element_text(hjust=c(0, 1),color = c('red','blue')))
bot
6 rompecabezas finales
Finalmente armarlo y ver:
library(patchwork)
up + mid + bot + plot_layout(nrow = 3,heights = c(1,0.2,0.1))
hice lo mejor que pude.
Bienvenido al grupo de intercambio Shengxin. Agrégueme a WeChat y también lo llevaré al chat grupal de WeChat 老俊俊生信交流群
. El código de datos se cargó al grupo QQ, bienvenido a unirse y descargar.
Código QR del grupo:
Lao Junjun WeChat:
Planeta del conocimiento:
Entonces, ¿estudiaste hoy?
¡Bienvenidos amigos a dejar comentarios!
¡Has click para dejar un mensaje!
Eso es todo por el intercambio de hoy, ¡estén atentos para el próximo!
Finalmente, bienvenidos a todos a compartir y reenviar , ¡sus Me gusta son mi aliento y afirmación !
Si crees que te ayuda mucho, ¡disfruta de una taza de agua feliz!
revisión anterior
◀ Artefacto de interacción de proteínas GeneMANIA
◀ Extraiga los resultados de enriquecimiento de GSEA para dibujar un hermoso mapa de GSEA
◀ ¡Un video imperdible para los principiantes del lenguaje R!
◀ pathview visualiza tus rutas genéticas!
◀ Resumen de parte de la serie Tweet
◀ Herramienta de enriquecimiento genético g:Profiler
◀ Aprenda a dibujar con Informes de celdas: marco Ribo-seq y distribución de longitud de lecturas
◀ control deslizante brillante
◀ ¡Habilidades de ajuste del eje para el paquete ggh4x!
◀...