R script does not work in snakemake
1
0
Entering edit mode
13 months ago

Hello,

I hava an R script (called dalink_st.r) to divide data frame into two columns and then save them to two separate files.

#!/usr/bin/Rscript 
lentele=read.table(snakemake@input[[1]], sep=",")

pirmas=lentele[1]
antras=lentele[2]

write.table(pirmas, snakemake@output[[1]])
write.table(antras, snakemake@output[[2]])

I call this script with snakemake rule.

rule all:
    input:
        "outputs/r/pirmas.txt",
        "outputs/r/antras.txt"

rule bandom_r:
    input:
        "inputs/r/lentele.csv"
    output:
        "outputs/r/pirmas.txt",
        "outputs/r/antras.txt"
    conda:
        "env/r4.yaml"
    script:
        "bins/dalink_st.r"

And once I call

snakemake --use-conda

I get an error message enter image description here

Would appreciate any ideas on why it is not working.

Thank you in advance.

Snakemake R • 1.8k views
ADD COMMENT
2
Entering edit mode
13 months ago

I have solved it. It was missing utils package in conda enviroment that contains funtions write.table and read.table.

conda:
    - conda-forge
dependencies:
    - r-base =4.0.3
    - r-r.utils =2.10.1
ADD COMMENT
1
Entering edit mode

Couldn't you just use awk? You're installing entire R packages to split a table into two.

ADD REPLY
1
Entering edit mode

Yeah I understand what you mean and it is true, and just the simple cut -d "," would work. But this was a small part of my bigger script in R used for differential gene expression analyses for writing DESeq objects to file.

ADD REPLY

Login before adding your answer.

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