Initial instructions:
I have attached here a spreadsheet that I will need two bar graphs.
There will be a separate graph for area only, and another for thickness only (I appreciate the thickness one will be much smaller!), so you can filter the dataframe by trait.
Then you can plot the "Go_term_simplified" along the y-axis and the x-axis will be -log10 of P_bonf.
Then, I was hoping we could color code the bars by Region. I have put in an additional "Color" column with colors that match the brain atlas we are using (I've tried to choose appropriate color names that are already in R!). It might be worthwhile to have a thin black outline around the bars since some of the colours are lighter and might be harder to see, like the beige/bisque2 colors.
You can keep the order of p-value bars as they appear in the spreadsheet.
Unlike the attached graph, we won't need to worry about the gene proportion part.
Final image:
#anotheer bar plot
#setup
rm(list=ls())
library(ggplot2)
library(ggsignif)
setwd("/Users/niniliu/Desktop/2020lab/carolina plots")
DDir='/Users/niniliu/Desktop/2020lab/carolina plots/'
GOdata <- read.csv("/Users/niniliu/Desktop/2020lab/carolina plots/GO_ontology_GWASgclus_forpresentation_space.csv")
head(GOdata)
#get -log10 ??? not sure if needed or not?
is.factor(GOdata$P.bonf)
is.numeric(GOdata$P.bonf)
GOdata$order <- numeric(28)
for(i in 1:28) {
GOdata$order[i] <- (28-i)
}
-log10(GOdata$P.bonf)
GOdata$neg_log10 <- -log10(GOdata$P.bonf)
#make area and thikness seperratee sets
areasub <- subset(GOdata,Trait == "area")
thicksub <- subset(GOdata,Trait == "thickness")
#plot area
plot <- ggplot(areasub, aes(fill=Region, y=neg_log10, x= reorder(GO.term.simplified,order))) +
geom_bar(position="dodge",stat = "identity" ,width=0.8, colour= 'black', size =0.2)+
coord_flip()+
labs( y= "-log10 P_bonf", x= "GO.term.simplified")+
scale_fill_manual("Region", values = c('anteromedialtemporal area' = '#782090',
'dorsolateralprefrontal area' = 'bisque2',
'dorsomedialprefrontal area'= '#FEFB54',
'inferiorparietal area' = '#CDF67C',
'occipital area' = '#E93225')) +
theme(axis.title.x= element_text(size = 20),
axis.text.x= element_text(size = 20),
axis.title.y = element_text(size = 20),
axis.text.y = element_text(size = 20),
legend.title = element_text( size = 20),
legend.text = element_text(size = 20),
axis.ticks.length=unit(.25, "cm"))
plot
ggsave(filename = "area19x15in.png", plot, width = 19, height = 15, dpi = 300, pointsize = 24, units = "in")
#############plot2
#plot
plot2 <- ggplot(thicksub, aes(fill=Region, y=neg_log10,x= reorder(GO.term.simplified,order))) +
geom_bar(position="dodge",stat = "identity" ,width=0.8, colour= 'black', size =0.1)+
coord_flip()+
labs( y= "-log10 P_bonf", x= 'GO.term.simplified')+
scale_fill_manual("Region", values = c('dorsolateralprefrontal thickness' = 'bisque2',
'medialprefrontal thickness' = "#FEFB54",
'occipital thickness'= '#E93225',
'superiorparietal thickness' = '#4BA52F')) +
theme(axis.title.x= element_text(size = 20),
axis.text.x= element_text(size = 20),
axis.title.y = element_text(size = 20),
axis.text.y = element_text(size = 20),
legend.title = element_text( size = 20),
legend.text = element_text(size = 20),
axis.ticks.length=unit(.25, "cm"))
plot2
ggsave(filename = "thickness19x7in.png", plot2, width = 19, height = 7, dpi = 300, pointsize = 24, units = "in")