This is a test version of Biostars. For the public version, visit https://www.biostars.org.
r script is not working in snakemake

Hi everyone, I created a snake file to download GEO datasets, I get this error message

rule download:
output: downloads/GSE67311.tar
jobid: 0

/bin/sh: 1: 1: not found
Error submitting jobscript (exit code 127):

Will exit after finishing currently running jobs.
Exiting because a job execution failed. Look above for error message

Here is the snakefile

configfile: "config.yml"
rule all:
    input:
        expand("downloads/{sample}.tar", sample=config["samples"])
rule download:
    output:
        "downloads/{sample}.tar"
    shell:
        "Rscript GH.R"

Here is the R script

library(GEOquery)
getGEOSuppFiles(snakemake@input)

How can I solve this?

snakemake geoquery r

2 answers

You have two choices and one problem

  • put GH.R in the special scripts directory, a recent Snakemake invention, and don't use RScript. You don't have input so you'll need to rethink that snakemake@input syntax.
  • use Rscript GH.R {wildcards.sample} but instead use args = commandArgs(trailingOnly=TRUE).

still the same error message, here is what I did 1- moved to scripts folder, (NB. I am using wsl-2)

snake file

    configfile: "config.yml"
    rule all:
        input:
            expand("downloads/{sample}.tar", sample=config["samples"])
    rule download:
        output:
            "downloads/{sample}.tar"
        shell:
            "Rscript scripts/GH.R {wildcards.sample}"

the R script

args = commandArgs(trailingOnly=TRUE)

library(GEOquery)
getGEOSuppFiles("args")

Did I do it right ?

probably it should be:

getGEOSuppFiles(args[1])

Thank you, it did work this way. It downloaded one of the files and then had this error message, I increased the latency time and looked online for a solution, normally increase latency time solves the problem but it did not work for mine

 MissingOutputException in line 5 of /mnt/d/metaa/snakefile.smk:
    Job Missing files after 1000 seconds. This might be due to filesystem latency. If that is the case, consider to increase the wait time with --latency-wait:
    /mnt/d/metaa/downloads/GSE67311.tar completed successfully, but some output files are missing. 2
    Shutting down, this might take some time.
    Exiting because a job execution failed. Look above for error message
    Complete log: .snakemake/log/2022-09-01T064501.006303.snakemake.log

snake file

configfile: "config.yml"
rule all:
    input:
        expand("/mnt/d/metaa/downloads/{sample}.tar", sample=config["samples"])
rule download:
    output:
        "/mnt/d/metaa/downloads/{sample}.tar"
    shell:
        "Rscript scripts/GH.R {wildcards.sample}"

probably because you didn't tell getGEOSuppFiles where to put the files it downloaded. Try the baseDir argument. https://www.rdocumentation.org/packages/GEOquery/versions/2.38.4/topics/getGEOSuppFiles

You seem to be stabbing at making the Snakefile run instead of testing the individual compoennts. First run your script in an R session. Then using the Rscript. Then try running the download rule with one file target. Then try your all.

Log in to answer this question.