Reputation: 63
I'm having issues trying to run a snakemake rule that invokes an R script. The relevant snakemake rule looks like this:
rule summarize_transcripts:
input:
lineages = expand("../final/{seq_run}/{exp}_transcript_lineages.csv", exp=EXP, seq_run=SEQ_RUN),
salmon_dir = expand("../salmon_quant_results/{experiment_id}", experiment_id=EXP),
output:
species_counts = expand("../final/{seq_run}/{exp}_sp_counts.csv", exp=EXP, seq_run=SEQ_RUN),
family_counts = expand("../final/{seq_run}/{exp}_family_counts.csv", exp=EXP, seq_run=SEQ_RUN)
shell:
'''
Rscript ./deseq2.R
'''
Here's the top of my R script, which fails at the S4 object call:
library('DESeq2')
library('tximport')
#Read in dataframe that contains the trinity ID's linked to lineage information
df <- read.csv(snakemake@input[["lineages"]], header=TRUE)
The libraries load fine, the error message states:
Error in read.table(file = file, header = header, sep = sep, quote = quote, :
object 'snakemake' not found
Calls: read.csv -> read.table
Execution halted
I'm trying to keep my dependencies organized within a conda .yml file, which looks like this:
name: test_env
channels:
- conda-forge
- bioconda
- r
- default
dependencies:
- star =2.7.1a
- trinity =2.12.0
- samtools =1.12
- salmon =1.4.0
- snakemake
- pandas
- r=4.1.0
- r-essentials
- bioconductor-deseq2
- bioconductor-tximport
Why is R not recognizing the snakemake inputs as described in the snakemake docs? I am running snakemake version 6.5.1.
Upvotes: 0
Views: 1042
Reputation: 206401
The examples use script:
rather than shell:
So change to
script:
"./deseq2.R"
rather than
shell:
'''
Rscript ./deseq2.R
'''
It looks like snakemake needs to inject R code into the script to define the snakemake
variable and it cannot do that with arbitrary shell commands. This is only done when the script file ends with ".R"
Upvotes: 2