Rstudio server in Snakemake
1
0
Entering edit mode
16 months ago
sakura • 0

Hello, I am new to using Snakemake and I am running a test script calling an R script. I work on a restricted server and I have access to a docker R studio server to run everything. However, it seems I am not able to connect the Snakemake to the Rstudio docker. Is that possible? Or do I need to install R?

This is my R script:

args = commandArgs(trailingOnly = TRUE)

num_cells = args[[1]]

write.table("Cells: 1000", num_cells)

This is the Snakemake script (Snakemake_Test1_PS.txt):

rule test_file:
    output:
        num_cells="all_cells.txt"
    shell:
        "Rstudio --no_environ Scripts/testing_snakemake.R {output.num_cells}"

Output:

$ snakemake -s Snakemake_Test1_PS.txt
Building DAG of jobs...
Using shell: /usr/bin/bash
Provided cores: 88
Rules claiming more threads will be scaled down.
Job counts:
        count   jobs
        1       read_file
        1

[Tue Jul 18 12:38:20 2023]
rule read_file:
    output: all_cells.txt
    jobid: 0

/usr/bin/bash: Rstudio: command not found
[Tue Jul 18 12:38:20 2023]
Error in rule read_file:
    jobid: 0
    output: all_cells.txt
    shell:
        Rstudio --no_environ Scripts/testing_snakemake.R all_cells.txt
        (one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)

Thank you!!

server Rstudio Snakemake • 1.6k views
ADD COMMENT
0
Entering edit mode

Why do you run Rstudio and not simply R?

ADD REPLY
0
Entering edit mode

I would like to run it in the R studio server environment I have. But either way just R doesn't work either. I get the exact same error

ADD REPLY
0
Entering edit mode

So do you run the script inside the docker? Do you run this specific part in the docker?

ADD REPLY
0
Entering edit mode

No, it doesn't work inside the docker because Snakemake isnt recognized. I run the docker using:

sudo docker exec -it rstudio_server4.2 bash

but mostly I use the Rstudio webpage interface linked to the docker

ADD REPLY
2
Entering edit mode
  1. You should avoid running anything with sudo, there is a way to run docker without a sudo, see here.
  2. You should tell snakemake in which environment it should run the rule. See here , you should add a docker: label to your rule.
ADD REPLY
0
Entering edit mode

Unfortunately I cannot do that. Although I have sudo access I wasn't given the docker account password. I understand that doesn't really make sense.

Running this:

rule test_file:
    output:
        num_cells="all_cells.txt"
    container:
        "docker://joseespinosa/docker-r-ggplot2"
    script:
        "Scripts/testing_snakemake.R"

Gives me this error

SyntaxError in line 4 of /redacted/Snakemake_Test1_PS.txt:
Unexpected keyword container in rule definition (Snakemake_Test1_PS.txt, line 4)
ADD REPLY
0
Entering edit mode

What version of snakemake are you using?

ADD REPLY
0
Entering edit mode

It is version 5.9.1

ADD REPLY
1
Entering edit mode

container support was introduced in 4.8.0 so it should work, but your version is quite old. I recommend updating to the latest version and giving it another try.

ADD REPLY
0
Entering edit mode

How do you normally use R/Rsudio on the server? It would appear that it is not installed / available. On our server, R is not available by default and requires running module load R to make it available. If it is not available at all you will need to install R and Rstudio for these commands to run.

ADD REPLY
0
Entering edit mode

I think thats my issue. I don't know how to have the console access the docker while still using the usual bash interface where Snakemake is. Or if that is even possible

ADD REPLY
0
Entering edit mode
16 months ago
DBScan ▴ 450

There are several ways you could do, I would suggest you make use of the container keyword in the test_file rule (see here Snakemake container). Generally it's also a good idea to use script instead of shell if you call R scripts (see here R script).

ADD COMMENT

Login before adding your answer.

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