slowkow / ggrepel

:round_pushpin: Repel overlapping text labels away from each other in your ggplot2 figures.
https://ggrepel.slowkow.com
GNU General Public License v3.0
1.21k stars 95 forks source link

ggrepel auto transform label to number #229

Closed phancanhtrinh closed 1 year ago

phancanhtrinh commented 1 year ago

Summary

I am using enrichGO from clusterProfiler to generate a GO object. I use dotplot function from enrichplot to make dotplot, I want to add geom_text for each dot with BgRatio (number/number). But, BgRatio is always automatic transform to a float number. Could you help me with this problem.

Minimal code example

dotplot(GO_comm_BvsP) + geom_text(aes(label=BgRatio))

image

Thank you very much!

aphalo commented 1 year ago

@phancanhtrinh I do not remember out of the top of my head the names of the columns from enrichGo. You can assemble the fraction with aes(label=sprintf("%i/%i", <responding genes>, <genes in the Go term>)). Both values should be integers. The <...> should be replaced by the names of the variables in your data.

This is not a 'ggrepel' specific question, so you would get an answer faster in Stackoverflow using tag [ggplot2]

phancanhtrinh commented 1 year ago

Hi Kamil It worked. Thank you very much.