dpeerlab/SEACells

gene score matrix with sparse format

Closed this issue · 1 comments

fl-yu commented

In the tutorial, the gene score matrix is exported by

write.csv(scores, "genescore.csv", quote=FALSE)

and imported to python using

gene_scores = pd.read_csv(data_dir + 'gene_scores.csv', index_col=0).T

However, when the cells number is large, say 150000, there will be an error
Error in asMethod(object) : Cholmod error 'problem too large' at file ../Core/cholmod_dense.c, line 102 in this command

scores <- as.matrix(scores)

that is converting a sparse matrix to a dense matrix. It seems R can not handle the conversion of such a large matrix, I wonder if there is a way of both exporting the gene score matrix from R and importing that to Python as a sparse matrix, as the genescore matrix is pretty sparse?

Python has a sparse matrix format using scipy. You can convert your .csv file to this sparse format, which should help with interfacing with R. Let me know if that works!