I have the following plot:
dat <- data.frame(
FunctionClass = factor(c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "Y", "Z"), levels=c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "Y", "Z")),
legend = c("A: RNA processing and modification", "B: Chromatin structure and dynamics", "C: Energy production and conversion", "D: Cell cycle control, cell division, chromosome partitioning", "E: Amino acid transport and metabolism", "F: Nucleotide transport and metabolism", "G: Carbohydrate transport and metabolism", "H: Coenzyme transport and metabolism", "I: Lipid transport and metabolism", "J: Translation, ribosomal structure and biogenesis", "K: Transcription", "L: Replication, recombination and repair", "M: Cell wall/membrane/envelope biogenesis", "N: Cell motility", "O: Posttranslational modification, protein turnover, chaperones", "P: Inorganic ion transport and metabolism", "Q: Secondary metabolites biosynthesis, transport and catabolism", "R: General function prediction only", "S: Function unknown", "T: Signal transduction mechanisms", "U: Intracellular trafficking, secretion, and vesicular transport", "V: Defense mechanisms", "W: Extracellular structures", "Y: Nuclear structure", "Z: Cytoskeleton"),
Differential_Abundance=c(2.1,2.2,3.4,3.3,2,1.1,0.1,0.1,-0.3,-0.9,3,2.1,-0.3,-0.9,-2,-1.2,-0.4,-0.5,-3,-2,-0.3,-2.1,-1.3,-2.2,-3)
)
library(ggplot2)
p <- ggplot(data=dat, aes(x=FunctionClass, y=Differential_Abundance, fill=legend))+
geom_bar(stat="identity", position=position_dodge(), colour="seashell")
p + guides (fill = guide_legend(ncol = 1))+
coord_flip() +
scale_x_discrete(limits = rev(levels(dat$FunctionClass))) +
xlab("COG Class") +
ylab("Differential Abundance (Treated/Untreated)")
Now, I want 4 similar plots (But with 4 "Differential_Abundance" values, but same y-axis) on the same page, with 4 separate labels (A, B, C and D). I guess, I have to move the legend to the bottom as well, as it would take up too much space in the site.
Anyway of doing this?
Thanks!