什么导致“必须从我的R包中请求至少一种颜色的色调调色板”错误只在基于Linux的构建?

问题描述 投票:10回答:1

我目前正在检查一些代码以实现跨平台兼容性。我正在使用Travis-CI在GitHub提交的ubuntu下构建我的R包。如果我删除了这一个单独的部分,它就会成功构建,但是如果我包含这个代码,我会收到错误:

Must request at least one colour from a hue palette.

这种构建很好并且在Windows和OS X上正常工作,这个问题只出现在ubutu构建中。我还想指出这是在执行后面的代码的插图生成步骤期间发生的。此错误消息似乎来自this function in the R scales library.

我有一些看起来像这样的数据:

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

我使用ggplot2来显示这些数据,我的命令大致如下:

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")

这是触发错误的部分。我觉得这个问题必须与aes()或scale_fill_manual()有点技术性。我试图看看是否以几种不同的方式改变它们会产生任何影响,但由于我使用的是Travis-CI,因此每次更改后需要花费一段时间进行测试。

有没有人看到可能导致问题的原因,或者对于为什么会发生这种情况有任何见解?首先十分感谢。

编辑:我想指出,我已将问题缩小到这段代码。

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

如果我做了以下它可以工作,但我的色彩丢失。

geom_point()

EDIT2:我已经修改了数据部分以使其更有用。复制/粘贴现在应该直接写字。

r ubuntu ggplot2 compiler-errors r-package
1个回答
2
投票

根据我的经验,当我最终为我的标签使用NA时会发生这种情况。我愿意打赌你的'变量'变量有NAs,而不是你想要ggplot调用col =参数的字符串。我也注意到你在aes内外都有col =两次,这可能有问题。我刚刚用Shiny碰到了这个,并且认为我会提供2美分。

© www.soinside.com 2019 - 2024. All rights reserved.