myles-lewis / locuszoomr

A pure R implementation of locuszoom for plotting genetic data at genomic loci accompanied by gene annotations.
GNU General Public License v3.0
18 stars 5 forks source link

Enabling labels for gg_scatter #15

Closed twillis209 closed 7 months ago

twillis209 commented 7 months ago

I have added labelling functionality to gg_scatter and locus_ggplot.

I used the geom_text_repel function from ggrepel to do this as using ggplot2's existing functionality too often leads to labels (especially lengthy ones containing rsIDs) overlapping points. I've modified the interface of the two aforementioned functions to add a ggrepel_args list of arguments which is passed to geom_text_repel. Despite the reasonably good default behaviour of geom_text_repel, I've found it's still necessary to tweak a few of the ggrepel parameters to get the best plot. I hope adding the ggrepel import and an argument to the two functions is not too obnoxious.

Lastly, I don't think this functionality deserves its own section in the vignette, but I've added a label = 'index' argument to the cowplot example just to show it in action.

twillis209 commented 7 months ago

I've just pushed another commit to gg_scatter_labels which drops the ggrepel_args argument and instead filters ... to fish out the formals for both gg_genetracks and geom_text_repel. Perhaps this is what you meant?

myles-lewis commented 7 months ago

Too late! I already merged. I'm working on the updates. Leave for the moment please and I'll check it out. Will come back to you for testing later if you don't mind!!

myles-lewis commented 7 months ago

I finished the modifications and pushed them to main branch. Do you want to test out the new version? You can now just pass ggrepel arguments such as nudge_x directly via the ... system. I tweaked the vignette to get it to work too.

twillis209 commented 7 months ago

So far so good, I'll let you know if anything comes up. Thanks for the quick turnaround.