tidyverse / ggplot2

An implementation of the Grammar of Graphics in R
https://ggplot2.tidyverse.org
Other
6.47k stars 2.02k forks source link

Error in min(c(x, xmin), na.rm = TRUE) : invalid 'type' (list) of argument #2610

Closed karawoo closed 6 years ago

karawoo commented 6 years ago

2584

Problem occurs in: FourCSeq, Rariant, RiboProfiling, Single.mTEC.Transcriptomes

From a quick look it seems that some interaction with ggbio might be the cause

karawoo commented 6 years ago

I believe this is coming up in ggbio's autoplot method. A reprex from ggbio docs, unfortunately not that minimal:

library("ggbio")
library("GenomicRanges")
set.seed(123)
gr.b <- GRanges(
  seqnames = "chr1",
  IRanges(
    start = seq(1, 100, by = 10),
    width = sample(4:9, size = 10, replace = TRUE)
  ),
  score = rnorm(10, 10, 3),
  value = runif(10, 1, 100)
)

p1 <- autoplot(gr.b, geom = "bar")
#> use score as y by default
#> Error in min(c(x, xmin), na.rm = TRUE): invalid 'type' (list) of argument

Created on 2018-05-15 by the reprex package (v0.2.0).

I think this is a tidyeval side effect, but I'm coming up against the limits of my ability to figure it out. I'm hoping I've narrowed it down enough that @hadley or @lionel- can point me in the right direction for the next step.

In the following line, ggbio looks up xmin values in the layer data: https://github.com/tengfei/ggbio/blob/fa214327b31bc0ecc9cfaf69e94a84d458c01e2c/R/utils.R#L138

With ggplot2 2.2.1, layer$mapping$xmin was a name, and this line got the relevant column of data out of the layer data data frame. In 2.2.1.9000 layer$mapping$xmin is a quosure, eval() doesn't have any effect as far as I can tell, and then finding the minimum value fails.

hadley commented 6 years ago

Yes, that's a tidy eval issue, so we can just describe in a bit more detail in the breaking changes. I'll do that tomorrow — thanks for the exploration!

karawoo commented 6 years ago

👍 we should make sure to notify ggbio even though revdepcheck doesn't flag it (I guess because it has no tests or examples). I'm pretty sure the rest of these packages are inheriting the problem from there.

hadley commented 6 years ago

@karawoo do you have time to finish this off today? It just needs a PR to docs mention this error under the tidy eval bullet. (No worries if not, I'll try and do later this afternoon).

karawoo commented 6 years ago

Yeah I can do it this evening

maureenbug commented 6 years ago

Hi, I was wondering if this was fixed, because I'm still running into this issue (even with a fresh RStudio restart and re-installation of packages), and don't really see a work around.

Thanks!

PS I only ran into this problem once I had to restart RStudio to update some packages... seemed like the package update was the problem (which, based on what was said above makes sense)

batpigandme commented 6 years ago

The change is a breaking change in ggplot2, so in terms of an update with a “fix”, you should look to ggbio.

maureenbug commented 6 years ago

Thanks!

lock[bot] commented 5 years ago

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/