我正在使用snakemake构建管道,并使用conda和singularity环境来确保可再现性。我遇到了一个错误,在这个错误中,我的绘图图上的文本被矩形替换。

在Linux和Mac系统上试验管道并禁用奇异容器之后,问题似乎源于缺少字体库,因为只有在我的Mac上只使用conda (--use-conda)运行管道时才会正常绘制文本。
奇异容器是从使用Debian /Linux的这个极小的坞映像构建的。我已经成功地创建了一个最小的示例管道,其中没有绘制文本。
# Snakefile
singularity: "docker://continuumio/miniconda3"
rule all:
input:
"mtcars-plot.png"
rule plot_mtcars:
output:
"mtcars-plot.png"
conda:
"minimal.yaml"
script:
"mtcars-test.R"# mtcars-test.R
library(ggplot2)
png("mtcars-plot.png")
ggplot(mtcars, aes(factor(cyl), mpg)) + geom_boxplot()
dev.off()# minimal.yaml
channels:
- bioconda
- conda-forge
- defaults
dependencies:
- r-base =3.6
- r-ggplot2若要绘制破图,请运行管道。
snakemake --use-conda --use-singularity在Debian /Linux上正确地使用R绘制文本时,我可能遗漏了哪些包/库?
发布于 2020-02-26 01:09:08
感谢MrFlick的评论,第二个链接说在R中文本支持需要mscorefonts包。
将mscorefonts添加到conda环境解决了这个问题
# minimal.yaml
channels:
- bioconda
- conda-forge
- defaults
dependencies:
- r-base =3.6
- r-ggplot2
- mscorefonts发布于 2022-11-29 14:06:47
conda config --set always_yes yes
conda config --add channels conda-forge
conda update --all
conda install r-ggplot2 r-rmarkdown
运行这个为我修复了它
https://stackoverflow.com/questions/60401617
复制相似问题