I want to create such a dotplot with dotplot of clusterprofiler. Here you can see that the Ontology terms are arranged on same plot with labels at the left of the plot. I was wondering if this can be done in a way that top five ontology terms for "Molecular function", "Cellular Components" and "Biological Processes" on the same plot with "Molecular function" terms on top with it's label on the left and then "Cellular Components" top five terms and so on.

Can anybody please help me how to do that ? The solution shouldn't necessarily use clusterprofiler, doing all this with ggplot can also be helpful.

The desired outcome

Edit: Here is an example data that I made with Chatgpt.

top_enriched <- data.frame(
  Category = rep(c("MF", "CC", "BP"), each = 5),
  Description = c(
    "DNA binding",
    "Kinase activity",
    "Transporter activity",
    "Cytoskeleton",
    "Plasma membrane",
    "Metabolic process",
    "Cellular nitrogen compound metabolic process",
    "Protein metabolic process",
    "Cellular component organization",
    "Nucleus",
    "Signal transduction",
    "Cytoplasm",
    "Ribosome biogenesis",
    "Mitochondrial organization",
    "Cell cycle"
  ),
  p.adjust = runif(15, 0, 0.05),
  Count = sample(5:20, 15, replace = TRUE),
  GeneRatio = runif(15, 0.5, 1)
)



ggplot(top_enriched, aes(x = GeneRatio, y = Description, color = p.adjust, size = Count)) +
  geom_point() +
  facet_grid(Category ~ .) +
  scale_color_gradient(low = "blue", high = "red") +
  ylab("")

The results of the code is shown in below image The result of the above code

In my real data I have separated the top five terms for each Ontology and made a separate data frame for that. The problem is if I use Facet grid it displays the description in all of the subplot of all of the Ontology terms. I rather want it to have the description related to the specific Ontology term on the subplot.

0

There are 0 best solutions below