首页 > 解决方案 > how to pass environment variable to snakemake markdown script

问题描述

I like the convenience of using the rmd script option in snakemake, like

    script:
        "scripts/report.Rmd"

But I'm having some trouble working out the best way to pass an environment variable to the script before the script is run. The problem I have is that I run this on a cluster, using PBS pro, and also use singularity to run the job.

In my case, I need to set the variable http_proxy before I start the script, so I can't pass it into the Rmd file.

I can do it if I export the variable first and use qsub -V option in my cluster submission section (Declares that all environment variables in the qsub command's environment are to be exported to the batch job), but I'd like to keep the workflow as self-contained as possible, so I don't really want to export all my variables to the batch job. Ideally, I'd like to specify the proxy as a variable either in a conig.yaml file, and pass it do the Rmd script.

Looking at the code, the Rmd script part executes it like:

self._execute_cmd("Rscript --vanilla {fname:q}", fname=fname)

Any suggestions would be welcome.

标签: rr-markdownsnakemakerscript

解决方案


推荐阅读