我正在使用snakemake
构建管道,并使用conda
和singularity
环境来确保可重复性。我遇到一个错误,我的绘图上的文本被矩形替换了
[在Linux和Mac系统上对管道进行了实验并禁用了奇点容器后,由于仅在使用conda
(--use-conda
)运行管道时才能正常绘制文本,因此问题似乎是由于缺少字体库引起的。在我的Mac上。
奇异性容器是使用Debian GNU / Linux的this miniconda docker映像构建的。我设法创建了一个最小的示例管道,其中不会绘制文本。
# 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 GNU / Linux上用R正确绘制文本,我可能缺少哪些软件包/库?
由于MrFlick的评论,第二个link表示mscorefonts
包对于R中的文本支持是必需的。
将mscorefonts
添加到conda
环境可解决此问题
# minimal.yaml
channels:
- bioconda
- conda-forge
- defaults
dependencies:
- r-base =3.6
- r-ggplot2
- mscorefonts