Running Rscript in Nextflow (Rmd file not found)
1
0
Entering edit mode
2.0 years ago
Eliveri ▴ 350

I have a nextflow DSL2 workflow which uses an Rscript in one of the processes. However when running the workflow (on a HPC cluster), the .Rmd file is not found. I tried various ways of referring to the file/path.

The path to the .Rmd file is defined as a param in the config file.

params {
    rscript = "./myscript.Rmd"
}
process {
    withName: run_report {
        conda = './env_R.yml'
    }   
} 

Process like this:

  rscript = file(params.rscript)
  ...
   process run_report {
    ...
    input:
    ...
    path(rscript)
    output:
    ...
    script:
    """
    Rscript -e "rmarkdown::render("$rscript")"
    """
}

I also tried this, directly referencing the .Rmd file and a variation like Rscript -e "rmarkdown::render("./myscript.Rmd")"

   process run_report {     
        ...
        script:
        """
        Rscript -e "rmarkdown::render("myscript.Rmd")"
        """
    }

Env file

name: R_kn
channels: 
  - defaults
  - conda-forge
dependencies: 
  - r-base=4.2.2
  - r-rmarkdown
Rscript R Nextflow • 1.9k views
ADD COMMENT
1
Entering edit mode

Could you try with absolute path to file?

ADD REPLY
1
Entering edit mode

1) Does it work on your local machine? 2) What is the exact error message you get? 3) Could you please share your .nextflow.log file? 4) Can you share the tree structure of your work dir? (Use the tree command)

ADD REPLY
1
Entering edit mode

Hi. Thank you for the tips. The accepted answer resolved my issue. It was due to the wrong use of quotes.

ADD REPLY
4
Entering edit mode
2.0 years ago
Rscript -e "rmarkdown::render("$rscript")"

you're using a double quote string inside a double quote string...

try

Rscript -e 'rmarkdown::render("$rscript")'

and use a full path for params.rscript

ADD COMMENT
0
Entering edit mode

Thank you! This resolved the issue! I will pay better attention to double quote strings vs single quote strings!

ADD REPLY

Login before adding your answer.

Traffic: 1684 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6