1.s4中属性相关
https://github.com/cole-trapnell-lab/monocle-release/issues/262
data <- as(as.matrix(seurat_object@assays$RNA@data), 'sparseMatrix')
上面这句有些许帮助,将对象属性数据转换为一个稀疏矩阵。
https://www.biostars.org/p/312933/ 将稀疏矩阵写入mtx文件,这个教程简直so good!
library(Matrix) # generate single-cell RNA seq data gbm <- replicate(10, rpois(10, 1)) rownames(gbm) <- paste0("gene_", 1:nrow(gbm)) colnames(gbm) <- paste0("cell_",1:ncol(gbm)) # save sparse matrix sparse.gbm <- Matrix(gbm , sparse = T ) head(sparse.gbm) writeMM(obj = sparse.gbm, file="matrix.mtx") # save genes and cells names write(x = rownames(gbm), file = "genes.tsv") write(x = colnames(gbm), file = "barcodes.tsv")
R中的稀疏矩阵格式为:dgCMatrix。