I have a nextflow workflow for which outputs are saved to a results
directory. The nextflow main.nf
script and rscript.Rmd
are in the workflow
directory.
When I run rscript render, the rscript.Rmd
automatically generates the output in the workflow
directory rather than the results
directory as desired.
To remedy this, I added the parameter output_dir to the render function. However the output ended up at this path: workflow/work/82/results/run_quality_report.html
. And there was error Missing output file(s)
publishDir params.outdir, mode:'copy'
output:
file('run_quality_report.html')
script:
"""
Rscript -e 'rmarkdown::render(input = "$rscript", output_dir ="${params.outdir}", params = list(directory = "${params.outdir}"))'
"""
Next I tried output_dir ="$baseDir/${params.outdir}"
. And the output ended up at this path: results/run_quality_report.html
. But still there was error Missing output file(s)
Does the output need to be at the .../work/82/results/...html
path with a symbolic link from results/...html
? Why is nextflow returning Missing output file error? How may I remedy this?
My nextflow.config parameters looks like this
params {
outdir = "../results"
}
The rscript header and some snippets looks like this
output:
html_document:
toc: true
toc_float: true
# runtime: shiny
params:
directory:
value: x
...
```{r , echo=FALSE, warning=FALSE}
inputfile <-read_tsv(file.path(params$directory, "filename.tsv"), show_col_types = FALSE)
Thank you so much! I had been stuck on this for days! The solution is so simple!
Indeed, sometimes it is so easy that we miss it. I was also stuck quite some time on that when I used Nextflow+rmarkdown for the first time. In our defense, rmarkdown is a little annoying in the regard that it puts outputs into the folder where the script is located and not to the current directory from where it is executed, and that that clashes with how Nextflow sees things :)