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

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 answer

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

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

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.

Log in to answer this question.