In need of help: Error in open.connection (file), opening tsv.gz & mtx.gz files
0
0
Entering edit mode
23 months ago
Emily ▴ 70

Trying to load the files and view the matrix as data table. This is what I have tried:

library(Matrix)
matrix_dir = "/Users/csb/Indexing/Exploratory data/data set/PIG/scRNA data/PBMC7_AllCells"
barcode.path <- paste0(matrix_dir, "barcodes.tsv.gz")
features.path <- paste0(matrix_dir, "features.tsv.gz")
matrix.path <- paste0(matrix_dir, "matrix.mtx.gz")
mat <- readMM(file = matrix.path)
feature.names = read.delim(features.path,
                           header = FALSE,
                           stringsAsFactors = FALSE)
barcode.names = read.delim(barcode.path,
                           header = FALSE,
                           stringsAsFactors = FALSE)
colnames(mat) = barcode.names$V1
rownames(mat) = feature.names$V1

But in stead i get this this error message:

Error in open.connection(file) : cannot open the connection
In addition: Warning message:
In open.connection(file) :
  cannot open file '/Users/csb/Indexing/Exploratory data/data set/PIG/scRNA data/PBMC7_AllCellsmatrix.mtx.gz': No such file or directory

Not sure where it went wrong, keeps failing when it tries to run at "mat <- readMM(file = matrix.path)"

dataframe Python R Studio • 1.1k views
ADD COMMENT
1
Entering edit mode

cannot open file '/Users/csb/Indexing/Exploratory data/data set/PIG/scRNA data/PBMC7_AllCellsmatrix.mtx.gz'

Please do not use spaces in directory/file names. If you replace the space with an _ this will work.

You could try escaping the spaces as /Users/csb/Indexing/Exploratory\ data/data\ set/PIG/scRNA\ data/PBMC7_AllCellsmatrix.mtx.gz but above option will be better.

ADD REPLY
1
Entering edit mode

you have a problem from these lines:

barcode.path <- paste0(matrix_dir, "barcodes.tsv.gz")
features.path <- paste0(matrix_dir, "features.tsv.gz")

Your directory path doesn't end with "/". When you do paste0 with directory and files, you will have an error like that (PBMC7_AllCellsmatrix.mtx.gz). Either you append / at the end of directory path or supply / in paste0 (/features.tsv.gz).

Btw, as GenoMax mentioned, do not use spaces or reserved characters in file paths and names.

ADD REPLY

Login before adding your answer.

Traffic: 2619 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6