help with mosaic plots

I’m trying to plot a mosaic style plot using geom_tile of the common GO terms from a DE experiment. As expected each GO term has multiple DE proteins associated with it. I thought I’d plot the GO ID on the x axis and fill each tile with a protein id. But this results in multiple ids being placed in each tile. How can I have a separate tile for each proteins id?

Enriched_GO_ID <- c("GO:0000062", "GO:0000062", "GO:0000062")
Description <- c("fatty-acyl-CoA binding", "fatty-acyl-CoA binding",
                 "fatty-acyl-CoA binding")
Uniprot.ID <- c("P49748", "P49748", "P22307", "P22307", "P13807", "P13807")
Cell.Line <- c("A", "B", "A", "B", "A", "B")
df <- data.frame(Enriched_GO_ID, Description, Uniprot.ID, Cell.Line)

All <- ggplot(df, aes(x = interaction(Enriched_GO_ID, Description ), 
                          y = Cell.Line))+
  geom_tile(color = "white",
            lwd = 2,
            linetype = 1)+ #now have white border between them
  geom_text(aes(label = Uniprot.ID), color = "white", 
            size = 3)+
  scale_fill_fermenter(palette = "Set2", breaks = c(5,2,1.4,0))+
  coord_fixed()+
  labs(title = "",
      y = "Cell Line Name",
      x = "GO Accession ID")+ 
  theme_classic()+ # white background
  theme(axis.text.x = element_text(size = 15, angle = 90),
        axis.text.y = element_text(size = 15),
        axis.title = element_text(size = 20, face = "bold"))
print(All)
dev.off()

Read more here: Source link