Hello everyone!
I new here. Actually I downloaded a huge big scRNA-seq .txt file from paper. And I want to analyze this seq data with R ~ "Seurat" package. But in order to do that, I have to convert this .txt format into .mtx file using R Matrix() package!!
And scRNA-seq data format looked like this:
library(Matrix)
micedata <- read.table(file = "mice.txt", header = T, sep="")
typeof(micedata)
#"list"
dim(micedata)
#[1] 14699 37070
And micedata looked like this:
head(micedata[1:5, 1:3])
GENE Aging_mouse_brain_portal_data_6_AAACCTGAGGCCCTTG Aging_mouse_brain_portal_data_6_AAACGGGAGAGACGAA
1 Sox17 0.000000 0
2 Mrpl15 1.340271 0
3 Lypla1 0.000000 0
But problem is that when i try to create sparse matrix it shows following errors:
# save sparse matrix
sparse.micedata <- Matrix(micedata, sparse = T )
Error in storage.mode(from) <- "double" :
(list) object cannot be coerced to type 'double'
I already stored genes.tsv and barcodes.tsv
# save genes and cells names
write(x = rownames(micedata), file = "genes.tsv")
write(x = colnames(micedata), file = "barcodes.tsv")
How can i convert to sparse matrix from micedata? Thank you
You actually don't have to convert. Seurat will take any matrix.
Read10X
is a helper function if you are starting with 10x data. Otherwise, just skip to theCreateSeuratObject
function.Great point, Igor.