andreyshabalin / MatrixEQTL

Matrix eQTL: Ultra fast eQTL analysis via large matrix operations
53 stars 16 forks source link

Matrix_eQTL_main() outputs error when `output_file_name` is not provided #7

Closed sritchie73 closed 5 years ago

sritchie73 commented 5 years ago

Minimal reproducible example:

First, load the package example data into the appropriate data structures:

library(MatrixEQTL)

# Toy data locations
base.dir = find.package('MatrixEQTL');
SNP_file_name = paste(base.dir, "/data/SNP.txt", sep="");
snps_location_file_name = paste(base.dir, "/data/snpsloc.txt", sep="");
expression_file_name = paste(base.dir, "/data/GE.txt", sep="");
gene_location_file_name = paste(base.dir, "/data/geneloc.txt", sep="");
covariates_file_name = paste(base.dir, "/data/Covariates.txt", sep="");

# Load toy data as per MatrixEQTL vignette
snps = SlicedData$new();
snps$fileDelimiter = "\t";      # the TAB character
snps$fileOmitCharacters = "NA"; # denote missing values;
snps$fileSkipRows = 1;          # one row of column labels
snps$fileSkipColumns = 1;       # one column of row labels
snps$fileSliceSize = 2000;      # read file in slices of 2,000 rows
snps$LoadFile(SNP_file_name);
snpspos = read.table(snps_location_file_name, header = TRUE, stringsAsFactors = FALSE);

gene = SlicedData$new();
gene$fileDelimiter = "\t";      # the TAB character
gene$fileOmitCharacters = "NA"; # denote missing values;
gene$fileSkipRows = 1;          # one row of column labels
gene$fileSkipColumns = 1;       # one column of row labels
gene$fileSliceSize = 2000;      # read file in slices of 2,000 rows
gene$LoadFile(expression_file_name);
genepos = read.table(gene_location_file_name, header = TRUE, stringsAsFactors = FALSE);

cvrt = SlicedData$new();
cvrt$fileDelimiter = "\t";      # the TAB character
cvrt$fileOmitCharacters = "NA"; # denote missing values;
cvrt$fileSkipRows = 1;          # one row of column labels
cvrt$fileSkipColumns = 1;       # one column of row labels
if(length(covariates_file_name)>0) {
  cvrt$LoadFile(covariates_file_name);
}

Run Matrix_eQTL_main() with the data but otherwise default arguments:

eQTLs <- Matrix_eQTL_main(snps = snps, gene = gene, cvrt = cvrt)
Error in Matrix_eQTL_main(snps = snps, gene = gene, cvrt = cvrt) : 
  nzchar(output_file_name) is not TRUE

It looks like the default for the argument, has either changed recently to "", or it has always been output_file_name = "" but this is no longer interpreted internally the same as output_file_name = NULL.

andreyshabalin commented 5 years ago

I think this always was like this. But I agree that it's an unpleasant inconsistency.

Fixed it in 0635b0eaa5a25bec12a8a800ff7bb1df106c7881