繁体   English   中英

带有 R 脚本的 Snakemake,错误:找不到蛇形对象

[英]Snakemake with R script, error: snakemake object not found

我在尝试运行调用 R 脚本的蛇形规则时遇到问题。 相关的蛇形规则如下所示:

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
        '''

这是我的 R 脚本的顶部,它在 S4 对象调用中失败:

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)

库加载正常,错误消息指出:

Error in read.table(file = file, header = header, sep = sep, quote = quote,  : 
  object 'snakemake' not found
Calls: read.csv -> read.table
Execution halted

我正在尝试将我的依赖项组织在 conda .yml 文件中,如下所示:

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

为什么 R 不能识别snakemake 文档中描述的snakemake 输入? 我正在运行蛇形版本 6.5.1。

这些示例使用script:而不是shell:所以更改为

script:
  "./deseq2.R"

而不是

shell:
    '''
    Rscript ./deseq2.R
    '''

看起来snakemake 需要将R 代码注入脚本来定义snakemake变量,而它不能用任意shell 命令来做到这一点。 这仅在脚本文件以“.R”结尾时完成

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM