In snakemake, you can call external scripts like so:
rule NAME:
input:
"path/to/inputfile",
"path/to/other/inputfile"
output:
"path/to/outputfile",
"path/to/another/outputfile"
script:
"path/to/script.R"
This gives convenient access to an S4 object named snakemake
inside the R script.
Now in my case, I am running snakemake on a SLURM cluster, and I need to load R with module load R/3.6.0
before an Rscript can be executed, otherwise the job will return:
/usr/bin/bash: Rscript: command not found
How can I tell snakemake to do that? If I run the rule as a shell instead of a script, my R script unfortunately has no access to the snakemake
object, so this is no desired solution:
shell:
"module load R/3.6.0;"
"Rscript path/to/script.R"