本文介绍了绘制气泡图:所有路径项都在一个轴上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的示例数据
a <- dput(head(df))
structure(list(Term = c("Reactome Gene Sets", "GO Biological Processes",
"GO Biological Processes", "GO Biological Processes", "GO Biological Processes",
"GO Biological Processes"), Pathway = c("R-MMU-191273", "GO:0034341",
"GO:0050900", "GO:0046942", "GO:0001817", "GO:0048871"), VVV = c("Cholesterol biosynthesis",
"response to interferon-gamma", "leukocyte migration", "carboxylic acid transport",
"regulation of cytokine production", "multicellular organismal homeostasis"
), p_value = c(-11.6414922875, -9.3148301923, -6.2150336681,
-5.9190690396, -5.8467499202, -5.767770517)), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"))
我在这里尝试显示路径及其各自的pvalue
Here Im trying to show the pathway and their respective pvalue
我的代码
ggplot(df, aes(x=Term,y=p_value)) +
geom_point(aes(size=abs(p_value))) +
#geom_text(data=df,label=df$Pathway) +
geom_label_repel(aes(label=Pathway), size=3)+
#scale_color_gradientn(colours = rainbow(5)) +
labs(
x='-log10(pvalue)', y=NULL,
color='p_value',size='pvalue'
) +
theme(
axis.title = element_text(face='bold'),
axis.text = element_text(face='bold')
)
我得到的输出是这个
有没有办法我也可以将Reactome基因设置在与GO Biological过程相同的轴或线上.我的想法是将所有这些都显示在一行中,其中p值显着表示气泡较大.
Is there a way where i can also get the Reactome gene set on the same axis or line as GO Biological process. My idea is to show all of them in a single line with significant pvalue showing bigger bubble.
任何建议或帮助都将不胜感激.
Any suggestion or help would be really appreciated.
推荐答案
您可以基于 Pathway
值应用 nudge_x
.
library(ggplot2)
library(ggrepel)
library(dplyr)
ggplot(df, aes(x=Term,y=p_value)) +
geom_point(aes(size=abs(p_value))) +
geom_label_repel(aes(label=Pathway), size=3,
nudge_x = ifelse(grepl('R-MMU', df$Pathway), 1, 3),
direction = "y") +
#scale_color_gradientn(colours = rainbow(5)) +
labs(
x='-log10(pvalue)', y=NULL,
color='p_value',size='pvalue'
) +
theme(
axis.title = element_text(face='bold'),
axis.text = element_text(face='bold')
)
要使所有东西都在同一X轴上:
To get everything on the same X-axis :
df %>%
mutate(X_value = '-log10(pvalue)') %>%
ggplot(aes(x=X_value,y=p_value)) +
geom_point(aes(size=abs(p_value))) +
geom_label_repel(aes(label=Pathway), size=3) +
labs(y=NULL, x = NULL,color='p_value',size='pvalue')
这篇关于绘制气泡图:所有路径项都在一个轴上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!