从RStudio内部或通过Rscript调用'system()'有什么不同?
我试图从运行外部工具,其中一个工具jaspar2meme生成一个文本文件,然后用作第二个工具fimo的输入。这是我的密码:从RStudio内部或通过Rscript调用'system()'有什么不同?,r,bash,rstudio,R,Bash,Rstudio,我试图从运行外部工具,其中一个工具jaspar2meme生成一个文本文件,然后用作第二个工具fimo的输入。这是我的密码: #!usr/bin/Rscript com1 <- "meme/bin/jaspar2meme" arg1 <- "-bundle jaspar_plant_2014.pfm" message("jaspar2meme command: ", com1, arg1) system2(command = com1, args = arg1, stdout =
#!usr/bin/Rscript
com1 <- "meme/bin/jaspar2meme"
arg1 <- "-bundle jaspar_plant_2014.pfm"
message("jaspar2meme command: ", com1, arg1)
system2(command = com1, args = arg1, stdout = "motif.fimo", wait = T)
com2 <- paste0("meme/bin/fimo")
arg2 <- paste0("--text --oc . --verbosity 1 --thresh 1.0E-4 --bgfile bg.fimo motif.fimo Genes_up_h16.ame")
message("FIMO command: ", com2, arg2)
system2(command = com2, args = arg2, stdout = "fimoresult.txt", wait = T)
当我通过源代码在RStudio中运行此代码时,它工作得非常好:文件motif.fimo由jaspar2meme生成,并由fimo使用以生成结果文件fimoresult.txt
当我从shell bash通过Rscript运行相同的脚本时,motif.fimo也会按预期生成,但fimoo找不到,并且fimoresult.txt仍然为空
到目前为止,我尝试使用system或system2,使用wait=T选项或不使用,指定motif.fimo的完整路径,但没有成功。我最终得到了它。。。RStudio和Rscript中的区域设置变量不同。jaspar2meme生成的motif.fimo文件在两种情况下看起来都一样,但显然不是。通过以下方式更改对system2的第一次调用:
解决我的问题。我相信RScript中没有加载方法,所以如果某些代码基于此,您可能需要加载方法?只需调用librarymethods?它不起作用。。。
system2(command = com1, args = arg1, stdout = "motif.fimo", wait = T, env = c("LC_NUMERIC=C"))