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

Error in `check_breaks_labels()`: ! `breaks` and `labels` must have the same length #7

Closed nickhir closed 10 months ago

nickhir commented 10 months ago

Hello,

I am using the latest version (locuszoomr_0.1.5 via devtools::install_github("myles-lewis/locuszoomr")) and encountered the following error when trying to run locus_ggplot:

Error in `check_breaks_labels()`:
! `breaks` and `labels` must have the same length

The interesting thing is, that locus_plot and locus_plotly work without any issue, so I dont think anything is "wrong" with the way I have prepared my data. I have

I have uploaded a small, randomized dataset (>50kb) with which one can reproduce the error: https://we.tl/t-eBpXs3UVAh

tmp <- data.table::fread("path/to/file")
loc_test <- locus(
    data = as.data.frame(tmp),
    chrom = "Chr",
    pos = "bp",
    p = "pC",
    labs = "SNP",
    seqname = chr,
    flank = 0,
    xrange = c(start, stop),
    ens_db = "EnsDb.Hsapiens.v75",
    LD = "1_247603584_C_T"
)
locus_plot(loc_test) #works
locus_plotly(loc_test) #works
locus_ggplot(loc_test) #doesnt work

Thank you very much in advance!

myles-lewis commented 10 months ago

Well spotted. It's a bug to do with dropping of levels in the LD column when it's converted to a factor. Fixed for both gg_scatter and scatter_plotly. I pushed the change to main branch, so if you reinstall from GitHub now it ought to work.