GO富集分析可视化
先上代码
rm(list = ls())
library(openxlsx)
library(tidyverse)
library(ggplot2)
data=read.xlsx("salmon_GOKEGG.xlsx",sheet=2)
names(data)
GO_pink<- data %>% dplyr::filter(.,FDR < 0.05 & Count >= 4)# & (type == "BP" | type == "MF" | type == "CC"))
names(GO_pink)
table(GO_pink$Category)
#
GO_pink <- within(GO_pink, type <- factor(Term, levels = c("BP", "CC", "MF", "KEGG")))
with(GO_pink, levels(type))
GO_pink <- within(GO_pink, Category <- factor(Module, levels = c("Salmon","Blue")))
with(GO_pink, levels(Category))
windowsFonts(myFont = windowsFont("Times New Roman"))
tiff(filename = "salmon+blue_GO.tiff",
width = 8,
height = 6,
units = "in",
pointsize = 5,res = 300)
ggplot2::ggplot(GO_pink,aes(FDR,
Description,
size=Count,
color=-log10(FDR)))+
geom_point()+
facet_grid(vars(type),vars(Category),shrink = TRUE,scales = "free_y",space="free")+
#theme(strip.background = element_rect(color="#FC4E07", fill=c("salmon","blue"),
#size=1.5, linetype="solid"))+
#facet_wrap(~type)+
#facet_wrap(~type,scales="free")+
scale_color_gradient(low="green",high = "red")+
theme_bw()+
scale_y_discrete(labels = function(x) str_wrap(x, width = 50) )+
theme(axis.title.x = element_text(size = 8,
color = "black",
face = "bold",
vjust = 0,
hjust = 0.5,
angle = 0,
family = "myFont"))+
theme(axis.title.y = element_text(size = 12,
color = "black",
face = "bold",
vjust = 0.5,
hjust = 0.5,
angle = 90,
family = "myFont"))+
theme(axis.text.y = element_text(size = 12,
color = "black",
face = "plain",
vjust = 0.5,
hjust = 1,
angle = 0,
family = "myFont"))+
theme(axis.text.x = element_text(size = 10,
color = "black",
face = "plain",
vjust = 0.5,
hjust = 0.5,
angle = 60,
family = "myFont"))+
theme(legend.text = element_text(size = 8,
color = "black",
face = "plain",
vjust = 0,
hjust = 0,
angle = 0,
family = "myFont"))+
theme(legend.title = element_text(size = 8,
color = "black",
face = "plain",
vjust = 0,
hjust = 0,
angle = 0,
family = "myFont"))
#theme(strip.placement = "outside")
#theme(strip.text.x = element_text(size = 30, colour = "#FC0043")) + # 设置分面的字字体大小、颜色、背景、边框,
#theme(strip.text.y = element_text(size = 15, colour = "#60FC00")) +
#theme(strip.switch.pad.grid = unit(1, "inch")) # 设置分面条带与坐标轴的距离
dev.off()