This is a test version of Biostars. For the public version, visit https://www.biostars.org.
converting a sc-RNA matrix from .txt to MatrixMarket .mtx file.

Hello, this is my first post on biostars! Thank you in advance for any help.

I'm having trouble converting a RNA-seq gene count sparse matrix from .txt to MatrixMarket .mtx file. I'm working with the gene count sparse matrix from this dataset.

And wanted to load the matrix in R so that I can filter cells by barcode out of the dataset. The first line of the .txt file is:

%%MatrixMarket matrix coordinate integer general

So I figured I'd be able to use the readMM() function however doing this gave me the error message:

Error in readMM(file = "~/scratch/rtrujillo/RNA-seq/sci-seq/gene_count.txt") : file is not a MatrixMarket file

How can I load this file in R?

matrixmarket rna-seq sc-rna-seq

2 answers

It works on my machine:

#/ download
wget -O - https://shendure-web.gs.washington.edu/content/members/cao1025/public/mouse_embryo_atlas/gene_count.txt | head > data.txt

#/ read in R:
library(Matrix)
Matrix::readMM("data.txt")
26183 x 2058652 sparse Matrix of class "dgTMatrix"
(...)

Weird, I removed gene_count.txt and ran the script successfully after redownloading it with wget. I had used curl before:

curl "https://shendure-web.gs.washington.edu/content/members/cao1025/public/mouse_embryo_atlas/gene_count.txt"

and never did anything after to manipulate the file. Is it possible the curl command altered gene_count.txt in some way wget didn't?

Log in to answer this question.