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
19 stars 5 forks source link

gg_scatter does not plot points correctly when beta is provided #25

Closed danwestern closed 2 months ago

danwestern commented 2 months ago

Hi @myles-lewis ,

Thanks for putting together a really wonderful package that makes customizing these plots so much easier.

I am attempting to plot QTL data in a stacked format using gg_scatter() and plot_grid() and came across a potential issue when trying to use the beta to plot effect direction. It seems that when all of the significant variants have a negative beta, the shape is set incorrectly to match the shape used for positive beta.

Here's a screenshot from the 'data' dataframe in my locus object, with the most significant variants that I am looking at: image

The top two variants are significant, and both have a negative beta. However, when I use gg_scatter() to plot them, this is the output: image

The shapes are plotted as expected when using scatter_plot(): image

If I can provide more detail please let me know, thanks again.

myles-lewis commented 2 months ago

Hi @danwestern ,

I just pushed a fix for this. Thanks for spotting this. It's to do with breaks needing to be specified in ggplot2. Otherwise the factor drops missing levels. It should work now. Do you want to install the GitHub version and try it out and let me know if it's fixed. Thanks.

Bw, Myles

danwestern commented 2 months ago

Hello again,

Everything looks great with the change! Thanks for the quick response and fix.

-Dan