This is a test version of Biostars. For the public version, visit https://www.biostars.org.
R: data.table::fread error when converting MAF files to data table

I want to merge the 50 MAF files with the sample information so that I can read it as a data.table and subset it.

library(maftools)

# Load MAF files
maf = system.file("extdata", list.files(path="mafs/"), package="maftools")

# Load sample information
si <- system.file("extdata", "sample-information.tsv", package="maftools")

d = read.maf(maf=maf, clinicalData=si)

Traceback:

Error in data.table::fread(file = maf, sep = "\t", stringsAsFactors = FALSE,  : 
  File '' does not exist or is non-readable. getwd()=='C:/Users/User/Documents/VanAllen'

> traceback()
3: stop("File '", file, "' does not exist or is non-readable. getwd()=='", 
       getwd(), "'")
2: data.table::fread(file = maf, sep = "\t", stringsAsFactors = FALSE, 
       verbose = FALSE, data.table = TRUE, showProgress = TRUE, 
       header = TRUE, fill = TRUE, skip = "Hugo_Symbol", quote = "")
1: read.maf(maf = maf, clinicalData = si)
1: data.table::fread(input = maf)

Maftools documentation: https://www.bioconductor.org/packages/release/bioc/manuals/maftools/man/maftools.pdf

data.table maftools bioconductor fread

Are you trying to read your own data or the example data from the package?

Then this entire extdata thing is wrong. extdata are meant for files provided by a package, e.g. for demo purposes. You have to run list.files() pointing to the directory where your files are, and also use the argument list.files(x=path/to/your/folder, full_names=TRUE).

1 answer

From the maftools manuals - read.maf:

maf tab delimited MAF file. File can also be gz compressed. Required. Alternatively, you can also provide already read MAF file as a dataframe.

And in your code you are supplying a list of files.

maf = system.file("extdata", list.files(...

It doesn't work when I want to read my own data.

From the codes you have provided, you are using example data from the package. In any case, ensure the code runs with an example data provided by the package, then check the file structure. Then ensure the real data structure is the same with the example data and try to read in your own data.

Log in to answer this question.