Nextflow Rmd render script cannot find input files?
1
0
Entering edit mode
21 months ago
Eliveri ▴ 350

My nextflow workflow calls Rmd render (NXF version 22.11.0-edge run with sge, apptainer in scratch directory). But the Rmd file is unable to find the files, directory path is passed in as a param.

nextflow.config has param outdir = "../results"

params.rscript = "$projectDir/run_quality_report.Rmd"

process run_report {
    publishDir params.outdir, mode:'copy'
    input:
    tuple val(pair_id), path('file.tsv'),
    path rscript

    output:
    file('report.html')

    script:
    """
    Rscript -e 'rmarkdown::render(input = "$rscript", output_dir = getwd(), params = list(directory = "${params.outdir}"))'
    """
}

Error message. The file is not being found.

Command executed:

  Rscript -e 'rmarkdown::render(input = "run_quality_report.Rmd", output_dir = getwd(), params = list(directory = "../results"))'

Command error:  
  processing file: run_quality_report.Rmd
  Error: '../results/Bam_stats_pf_Final.tsv' does not exist in current working directory ('/scratch/769451.1.long.q/nxf.jI7GjjSY7c').
  Execution halted

Work dir:
  /wynton/scratch/finterly/new_workflow/work/91/b1888cccc40f39d394ed315b4ba432

The Rmd file looks like this:

title: ...
params:
  directory:
    value: x
---
```
file_df <-read_tsv(file.path(params$directory, "file.tsv"), show_col_types = FALSE)
```
render r rmd nextflow • 2.0k views
ADD COMMENT
1
Entering edit mode

tuple val(pair_id), path('file.tsv'),

I'm surprised that the input contains a path with a quoted string. It looks like an error.

ADD REPLY
0
Entering edit mode

Hi. Thank you for bringing this to my attention. I will try my best to leave comments and validation (as in select an answer?).

ADD REPLY
2
Entering edit mode
21 months ago

use a full path for params.outdir

not:

  --outdir ../results/Bam_stats_pf_Final.ts

but

  --outdir ${PWD}/../results/Bam_stats_pf_Final.ts
ADD COMMENT
1
Entering edit mode

and it looks like it was the same problem as previously: Nextflow: [E::bwa_idx_load_from_disk] fail to locate the index files ...

ADD REPLY
0
Entering edit mode

Thank you. Making sure the file path is a full path and passing the outdir param in as an input resolved the issue.

input:
    tuple val(pair_id), path(file_tsv),
    path rscript
    path outdir
ADD REPLY

Login before adding your answer.

Traffic: 2441 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