10

I am currently checking some code for cross-platform compatibility. I am using Travis-CI to build my R package under ubuntu on GitHub commits. If I eliminate this one single part, it successfully builds, but if I include this code, I receive the error:

Must request at least one colour from a hue palette.

This builds fine and works properly on windows and OS X, this issue is only appearing on the ubutu build. I also want to point out this is happening during the vignette build step that executes the code that follows. This error message appears to originate from this function in the R scales library.

I have some data that looks like this:

gene <- c("ISG20","ISG20","HEY1","ISG20","ACTB","MDM2","CDYL","HEY1","ACTB","UTP3","MDM2") 
variable <- c("6h_ebov","1d_ebov","1d_ebov","2d_ebov","2d_ebov","2d_ebov","2d_restv","2d_restv","2d_restv","2d_restv","2d_restv")
value <- c(-4.54267311671893,0.523667984831315,0.552671011358972,3.97643775389922,0.888734866999937,1.26719604773752,1.31653814202267,2.28445821019938,1.00301304727651,1.86941283629719,1.33916249182697 )

filteredList <- data.frame(gene,variable,value)

> head(filteredData)
   gene variable      value
1 ISG20  6h_ebov -4.5426731
2 ISG20  1d_ebov  0.5236680
3  HEY1  1d_ebov  0.5526710
4 ISG20  2d_ebov  3.9764378
5  ACTB  2d_ebov  0.8887349
6  MDM2  2d_ebov  1.2671960

I am using ggplot2 to display this data, my command is approximately as follows:

library(ggplot2)
library(ggthemes)

stata_long_pal = c(stata_pal("s2color")(15), stata_pal("s1rcolor")(15))
plot_out <- ggplot(filteredList, aes(x=value, y=factor(variable, levels=as.character(unique(variable)), ordered=TRUE), label=variable, col=variable)) + 
        geom_point(stat='identity', aes(col=variable), size=3) +
        theme_stata() + 
        scale_fill_manual(values=stata_long_pal) + 
        theme(axis.text.y = element_text(angle = 45, hjust = 1), plot.title = element_text(size=14, face="bold", hjust=0)) + 
        guides(col=guide_legend(ncol=6%/%3)) +
        theme(legend.text = element_text(size=12)) +
        theme(legend.title=element_blank()) +
        theme(axis.text=element_text(size=12, face="bold")) +
        theme(text = element_text(size=22,margin = margin(t = 0, r = 10, b = 0, l = 0))) +
        labs(x="", y="", title="Differentially Expressed Genes", subtitle="Log2 Fold-Change")

This is the part that is triggering the error. I feel like the issue has to be some little technicality with either the aes() or with scale_fill_manual() maybe. I am attempting to see if changing these around in a few different ways has any effect, but because I'm using Travis-CI it takes quite a while to test after each change.

Does anyone see what might be causing the issue or have any insights into why this is happening? Thanks very much in advance.

EDIT: I would like to point out that I have narrowed the problem down to this bit of code.

geom_point(stat='identity', aes(col=variable), size=3) 

If I do the following it works but my coloring is lost.

geom_point()

EDIT2: I have modified the data section to be more useable. Copy/paste should word directly now.

Adam Price
  • 810
  • 2
  • 11
  • 21
  • If you paste your code in such a way that it can be directly copied and pasted into an R terminal and work it would be easier to reproduce your example. – Prevost Oct 04 '18 at 20:34
  • @Prevost I have updated the data section. Should be copy/paste-able now. – Adam Price Oct 05 '18 at 15:21
  • Are you aware that you are using `ggplot(data = filteredList)` for your `ggplot` data while your actual `dataframe` is named `filteredData`? `filteredList` doesn't exist in your sample code. – Prevost Oct 05 '18 at 18:37
  • @Prevost Yeah, just a typo when I made the sample data. – Adam Price Oct 05 '18 at 18:53
  • `aes(col=variable)` is also declared twice. Sorry, I don't have ubuntu on my machine (missed that in the question)! – Prevost Oct 05 '18 at 18:54
  • @Prevost Yeah I noticed that, but it doesn't actually make any difference. I've corrected it in my testing and it's not the problem. Hopefully I'll figure out how to get access to an ubuntu machine soon or someone else here will have some good insights. Testing via travis-ci is not good for bug fixing. – Adam Price Oct 05 '18 at 18:57
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/181365/discussion-between-prevost-and-adam-price). – Prevost Oct 05 '18 at 18:59
  • 1
    @AdamPrice Can you throw up a link to your GitHub repo? The code you've posted here runs without error on my machine running Ubuntu 18.04 – duckmayr Oct 09 '18 at 09:24
  • @AdamPrice: your code also runs fine in my machine, an Archlinux. – Ramiro Magno Feb 21 '19 at 20:19

1 Answers1

5

In my experience, this happens when I end up with NAs for my labels. I'm willing to bet your 'variable' variable has NAs instead of the strings you are wanting for col= argument in your call to ggplot. I also noticed you have col= twice both in and outside aes which could be problematic. I just ran into this using Shiny, and thought I would offer my 2 cents.

roberty boberty
  • 175
  • 2
  • 8