基于cluster profile的分面双元素点图

本文介绍了使用R语言对KEGG代谢途径数据进行处理,通过过滤、分组和可视化,比较了不同类型的微生物(Develop、Resistance和Flavour)在特定代谢途径中的基因表达差异,以p-value图的形式展示结果。
摘要由CSDN通过智能技术生成
KEGG_FE_data$GeneRatio = KEGG_FE_data$GeneRatio %>% 
  factor(levels = KEGG_FE_data$GeneRatio[order(KEGG_FE_data$GeneRatio %>% str_extract(".*/") %>%
                                               str_replace_all("/","")%>%
                                               as.numeric())] %>% unique() )

KEGG_FE_plot = KEGG_FE_data %>% 
  filter(ID %in% c("map00140","map00981","map04977","map04745")) %>% 
  mutate(group = "Develop") %>% 
  bind_rows(KEGG_FE_data %>% 
                filter(ID %in% c("map05168","map05169")) %>% 
                mutate(group = "Resistance") ) %>% 
  bind_rows(KEGG_FE_data %>% 
              filter(ID %in% c("map00052","map00500","map00564","map00250",
                               "map00260","map00350","map00380","map00410")) %>% 
              mutate(group = "Flavour"))

KEGG_FE_plot$group  =  KEGG_FE_plot$group %>% factor(levels = c("Develop","Resistance","Flavour"))
KEGG_FE_plot$GeneRatio =KEGG_FE_plot$GeneRatio %>% as.character()

for (i in 1:nrow(KEGG_FE_plot)) {
  KEGG_FE_plot$GeneRatio[i] = 
  KEGG_FE_plot$GeneRatio %>% .[i] %>% as.character() %>% str_split("/") %>% unlist() %>% .[1] %>% as.numeric()/
    c(KEGG_FE_plot$GeneRatio %>% .[i] %>% as.character() %>% str_split("/") %>% unlist() %>% .[2]%>% as.numeric())
  
}
KEGG_FE_plot$GeneRatio = KEGG_FE_plot$GeneRatio  %>% as.numeric()

pdf(file = "../Fic/fic.30.2.FE_kegg.pdf",width = 11.25,height = 7.5)
ggplot(data = KEGG_FE_plot,aes(x = GeneRatio, y = Description)) +
  geom_point(aes(size = Count,color = pvalue)) +
  scale_color_gsea()+
  scale_y_discrete(labels=function(x) str_wrap(x, width=32)) +
  theme_bw() + 
  theme(axis.title = element_text(size = 8),axis.text = element_text(size = 8, colour = "gray10")) +
  labs(y = NULL)+
  scale_y_discrete(labels=function(x) str_wrap(x, width=35)) + 
  theme(axis.title = element_text(face = "bold"),
        axis.text = element_text(face = "bold"),
        plot.title = element_text(face = "bold")) +
  labs(colour = "pvalue")+
  facet_grid(group ~ ., scales = "free", space = "free")


dev.off()


KEGG_ME_data$GeneRatio = KEGG_ME_data$GeneRatio %>% 
  factor(levels = KEGG_ME_data$GeneRatio[order(KEGG_ME_data$GeneRatio %>% str_extract(".*/") %>%
                                                 str_replace_all("/","")%>%
                                                 as.numeric())] %>% unique() )
KEGG_ME_plot = KEGG_ME_data %>% 
  filter(ID %in% c("map00140","map00260","map00830","map00981")) %>% 
  mutate(group = "Develop") %>% 
  bind_rows(KEGG_ME_data %>% 
              filter(ID %in% c("map00190","map00590","map00480","map00900",
                               "map00980","map00982","map04610")) %>% 
              mutate(group = "Resistance") ) %>% 
  bind_rows(KEGG_ME_data %>% 
              filter(ID %in% c("map01212","map00010","map00040","map00500","map00071",
                               "map00565","map00600","map00280","map00360","map00410")) %>% 
              mutate(group = "Flavour"))
KEGG_ME_plot$group  =  KEGG_ME_plot$group %>% factor(levels = c("Develop","Resistance","Flavour"))
KEGG_ME_plot$GeneRatio =KEGG_ME_plot$GeneRatio %>% as.character()

for (i in 1:nrow(KEGG_ME_plot)) {
  KEGG_ME_plot$GeneRatio[i] = 
    KEGG_ME_plot$GeneRatio %>% .[i] %>% as.character() %>% str_split("/") %>% unlist() %>% .[1] %>% as.numeric()/
    c(KEGG_ME_plot$GeneRatio %>% .[i] %>% as.character() %>% str_split("/") %>% unlist() %>% .[2]%>% as.numeric())
  
}
KEGG_ME_plot$GeneRatio =KEGG_ME_plot$GeneRatio %>%as.numeric()
pdf(file = "../Fic/fic.31.2.ME_kegg.pdf",width = 11.25,height = 7.5)
ggplot(data = KEGG_ME_plot,aes(x = GeneRatio, y = Description)) +
  geom_point(aes(size = Count,color = pvalue)) +
  scale_color_gsea()+
  scale_y_discrete(labels=function(x) str_wrap(x, width=32)) +
  theme_bw() + 
  theme(axis.title = element_text(size = 8),axis.text = element_text(size = 8, colour = "gray10")) +
  labs(y = NULL)+
  scale_y_discrete(labels=function(x) str_wrap(x, width=35)) + 
  theme(axis.title = element_text(face = "bold"),
        axis.text = element_text(face = "bold"),
        plot.title = element_text(face = "bold")) +
  labs(colour = "pvalue")+
  facet_grid(group ~ ., scales = "free", space = "free")
dev.off()


KEGG_dot_plot = KEGG_FE_plot %>% mutate( type = "FE") %>% bind_rows(
  KEGG_ME_plot %>% mutate(type = "ME") 
)

pdf(file = "../")
ggplot(data = KEGG_dot_plot,aes(x = GeneRatio, y = Description)) +
  geom_point(aes(size = Count,color = pvalue,shape = type)) +
  scale_color_gsea()+
  scale_y_discrete(labels=function(x) str_wrap(x, width=32)) +
  theme_bw() + 
  theme(axis.title = element_text(size = 8),axis.text = element_text(size = 8, colour = "gray10")) +
  labs(y = NULL)+
  scale_y_discrete(labels=function(x) str_wrap(x, width=35)) + 
  theme(axis.title = element_text(face = "bold"),
        axis.text = element_text(face = "bold"),
        plot.title = element_text(face = "bold")) +
  labs(colour = "pvalue")+
  xlim(0,0.07)+
  facet_grid(group ~ type, scales = "free", space = "free")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

刘融晨

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值