how to display the enrichment of multiple group comparsions?

如何展示多种比较情况下富集情况?

🌰( ),如何实现下边这篇论文里的 Fig 6 和 Fig 7 。

Jie, Z. et al. The gut microbiome in atherosclerotic cardiovascular disease. Nat. Commun. 8, 845 (2017).

Talk cheap, show code :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
library('ggplot2')
library('reshape2')
dt = read.table('inputfile', header = T, sep = '\t') #输入格式是:map\tGroup1\tGroup2…\tLevel; map 是小类,Level 是大类,去看论文里的例子,就能明白
dt_melt = melt(dt, id.vars = c('map', 'Level'))
#order = c('Lipid metabolism', 'Amino acid metabolism', 'Carbohydrate metabolism', 'Metabolism of cofactors and vitamins', 'Xenobiotics biodegradation and metabolism', 'Antimicrobial resistance', 'Membrane transport', 'Cell motility', 'Glycan biosynthesis and metabolism', 'Metabolism of terpenoids and polyketides', 'Energy metabolism') #自定义排序
dt_melt$Level = factor(dt$Level,levels = order)
pdf('output.pdf', width = 6, height = 6)
ggplot(dt_melt, aes(y = value, x = map, fill = value>0)) +
geom_bar(stat = "identity") +
scale_fill_manual(values= c('#24af2d','#e80211')) +
geom_hline(aes(yintercept = 1.65), linetype = "dashed", size = 0.2, color = 'grey') + #设置阈值线,1.65 是单尾的 95% 置信区间;也可以看到论文里有 1.96 ,是双尾的值。
geom_hline(aes(yintercept = -1.65), linetype = "dashed", size = 0.2, color = 'grey') +
coord_flip() +
labs(x="Pathway",y="Pathway report score") +
facet_grid(Level ~ variable, scales = "free", space = "free_y") + #控制图形的各种间距,可以自己注释掉观察效果
theme_bw() +
theme(axis.text = element_text(colour = 'black', size = 6),
axis.title = element_text(size = 12),
panel.background = element_rect(colour = "black", size = 0.6),
#legend.key = element_blank(),
#legend.text = element_text(size = 8),
panel.grid =element_blank(),
legend.title = element_blank(), legend.position='none',
plot.margin = unit(c(0.1, 0.1, 0.1, 0.1 ), 'in'))
dev.off()

碎碎念:好多写脚本时候的想到的点现在完全都忘记了…果然还是需要多记录呀 +.+
完结撒花~

(✪ω✪)