Reputation: 129
I am running a script in R using command: Rscript gtex_tiss_chrom.R 1 The content of this script is:
source("../code/gtex_v7_nested_cv_elnet.R")
"%&%" <- function(a,b) paste(a,b, sep='')
argv <- commandArgs(trailingOnly = TRUE)
chrom <- argv[1]
#tiss <- argv[1]
#chrom <- argv[2]
snp_annot_file <- "../output/snp_annot.chr" %&% chrom %&% ".txt"
gene_annot_file <- "../output/gene_annot.parsed.txt"
genotype_file <- "../output/genotype.chr" %&% chrom %&% ".txt"
expression_file <- "../output/transformed_expression.txt"
covariates_file <- "../output/covariates.txt"
prefix <- "Model_training"
main(snp_annot_file, gene_annot_file, genotype_file, expression_file, covariates_file, as.numeric(chrom), prefix, null_testing=FALSE)
the error: Error in file(file, "rt") : cannot open the connection Calls: main ... get_filtered_snp_annot -> %>% -> distinct -> filter -> read.table -> file In addition: Warning message: In file(file, "rt") : cannot open file 'snp_annot.chrNA.txt': No such file or directory Execution halted
Upvotes: 0
Views: 155
Reputation: 8621
Based on the discussion in the comments, here is the answer.
In the code:
chrom <- argv[1]
: assigns the first argument to the chrom
variable.snp_annot_file <- "../output/snp_annot.chr" %&% chrom %&% ".txt"
. This will assign the filename "../output/snp_annot.chr<VALUE OF CHROM>.txt"
.argv[1]
is not assigned, chrom would be assigned NA."../output/snp_annot.chrNA.txt"
.The solution is to modify the code slightly:
snp_annot_file <- chrom
.FYI:
snp_annot_file <- "../output/snp_annot.chr" %&% chrom %&% ".txt"
Upvotes: 1