This is some notes on using the facet_grid function in ggplot2.
My data looks like this:
Basically it’s a collection of enriched functional clusters (gene family and pfam) on each chromosome. I would like to plot those gene numbers as bar (at least 4 genes) and label those marked “yes” with the function names. From ggplot2 facet_grid() function seems suitable in categorising the data into each chromosome. And I used geom_bar and geom_label to plot and label clusters. For the chromosome I used geom_rect to draw a rectangle (not ideal though).
Here is the script with notes to myself:
There is still one problem with the plot: some labels are overlapped with bars. Not sure which function to avoid this?