Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Declare script as input #1

Open
mfansler opened this issue Dec 18, 2022 · 0 comments
Open

Suggestion: Declare script as input #1

mfansler opened this issue Dec 18, 2022 · 0 comments

Comments

@mfansler
Copy link

Nice example - I came here from the SO answer.

Unlike the other rule that uses a script: key, the use of shell: key shown below means that Snakemake will not track the dependency between this rule and the scr/test-script.R file:

shell:
"Rscript scr/test-script.R \
--input {input.data} \
--output {output.out} \
--myFactor {params.myFactor}"

I would recommend it as better practice to

  • declare the script in the input:
    input:
      script='scr/test-script.R',
      data='data/testData.rds'
  • use that Jinja variable in the shell: command, e.g., RScript {input.script} ...

This way, if the script has changes made to it, Snakemake can use them to invalidate any downstream objects that may have used an older version.

At least, that's what I picked up from using that style of integration (custom arguments to the scripts) for a couple years. Personally, I moved on to favor the script: style (using the snakemake object), and find it clearer to maintain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant