setwd('D:\\14_rice_G4_two\\04_histone_cluster\\01_cluster_bed')
data3<-read.table('1plot_go.txt',sep='\t',header = 1)
# colnames(data)<-c('T_specific',)
library(ggplot2)
library(dplyr)
library(reshape2)
colnames(data3)
data<- melt(data3,id.vars=c("Description","Ontology"),
variable.name=c("type"),value.name="value")
data$v2<- -log10(data$value)
data$v2[which(!is.finite(data$v2))] <- 0
library(stringr)
data$Ontology<-str_replace(data$Ontology, "F","M F")
data$Ontology<-str_replace(data$Ontology, "P","B P")
data$Ontology<-str_replace(data$Ontology, "C","C C")
# data$type<-str_replace(data$type, "X","")
# table(data$type)
# write.table(data,file = './1plot_goxiu.txt',sep = '\t',quote = F,row.names = F)
# data<-read.table('./1plot_goxiuafter.txt',sep = '\t',header = 1)
# table(data$type)
# table(data$sample)
# data$sample<- factor(data$sample,
# levels= c("BCD vs CON","YCD vs CON","YCD vs BCD"),ordered = TRUE)
head(data)
> head(data)
Description Ontology type value v2
1 regulation of metabolic process B P cluster_1 0.0015 2.823909
2 regulation of gene expression B P cluster_1 0.0015 2.823909
3 regulation of macromolecule metabolic process B P cluster_1 0.0015 2.823909
4 transcription B P cluster_1 0.0015 2.823909
5 biological regulation B P cluster_1 0.0016 2.795880
6 regulation of cellular process B P cluster_1 0.0017 2.769551
ggplot(data, aes(type, Description, fill = v2))+
geom_tile(color = "black")+
# scale_fill_gradient2( high = "blue", mid = "white",space = "Lab",
# name="-log10(FDR)",limits=c(0,4),oob = scales::squish) +#
scale_fill_gradientn(colours=c("#FFFFFF","#FFA500","#FF0000"),name="-log10(FDR)",
limits=c(0,5),oob = scales::squish)+
facet_grid(Ontology~.,scales="free",space="free") +
# theme(axis.text.x =element_blank())+
theme_minimal()+ # minimal theme
theme(axis.text.x = element_text(angle = 45, vjust = 1.3, face = "bold",
size = 10, hjust = 1.3),
axis.text.y = element_text(face = "bold"))+
# coord_fixed()+
theme(strip.text.x = element_text( face="bold",size = 12),
#size=8,angle=75
strip.text.y = element_text( face="bold",size = 12),
strip.background = element_rect(colour = "white", fill = "grey"),
axis.title = element_text(face = "bold",
size = "13",color = "black"),
axis.text.x = element_text(face = "bold",color = "black",angle = 45,
size = 11, hjust = 1, vjust = 1),
axis.text.y = element_text(face = "bold",size = 11,color = "black"),
legend.text = element_text(size = 10,face = "bold"),
legend.title = element_text(size = 10,
face = "bold"),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.grid.major = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
axis.ticks = element_blank())
结果
气泡图
ggplot(data, aes(x=GeneRatio, y=Description)) +
geom_point(aes( size= Count , colour = -log10(p.adjust)) ) +
# scale_y_discrete(limits=Edata$Description)+
# ggtitle("GO enrichment") +
labs(x = "",y = "")+
scale_color_gradient(low = 'blue', high = 'red',name="-log10(p.adjust)") +
# theme_minimal()+
# xlim(range(Edata$type)) +
theme(strip.text.x = element_text( colour = 'black',size = 13),#size=8,angle=75
strip.text.y = element_text( colour = 'black',size = 13),
strip.background = element_rect(colour="white", fill="grey"),
axis.title = element_text(face = "bold",
size = "13",color = "black"),
axis.text.x = element_text(face = "bold",color = "black",
size = 12, hjust = 0.5, vjust = 0.5),
axis.text.y = element_text(face = "bold",size = 12,color = "black"),
legend.text = element_text(size = 10,face = "bold"),
legend.title = element_text(size = 10,
face = "bold"),
legend.position ='right',
# legend.key.size =
panel.background = element_rect(fill="transparent"),
panel.border =element_rect(fill='transparent', color='black'),
# panel.grid.major.y = element_blank(),
# panel.grid.minor = element_line(colour = "grey95", size = 0.25),
panel.grid.major.y = element_line(colour = "grey95", size = 1),
# panel.grid.major.x = element_blank(),
panel.grid.major.x = element_line(colour = "grey95", size = 1),
plot.title = element_text(lineheight=.8, face="bold", hjust=0.5, size =14),)