Seurat: Why use Matrix package?

Created on 13 Jun 2018  路  2Comments  路  Source: satijalab/seurat

When we calculate the "percent.mito", the Matrix package is used:
percent.mito <- Matrix::colSums([email protected][mito.genes, ])/Matrix::colSums([email protected])

But I think it is the same with that in base package: base::colSums

Can we use the base package directly instead of the Matrix package here?

Analysis Question

Most helpful comment

Hi,

You can use the base::colSums() function if your data is of class data.frame. However, Seurat stores the normalised data as a sparse matrix (of class dgCMatrix), in which case the base::colSums() function returns an error:

> class(x = obj@data)
[1] "dgCMatrix"
attr(,"package")
[1] "Matrix"
> base::colSums(obj@data)
Error in base::colSums(obj@data) : 
  'x' must be an array of at least two dimensions

Best,
Leon

All 2 comments

Hi,

You can use the base::colSums() function if your data is of class data.frame. However, Seurat stores the normalised data as a sparse matrix (of class dgCMatrix), in which case the base::colSums() function returns an error:

> class(x = obj@data)
[1] "dgCMatrix"
attr(,"package")
[1] "Matrix"
> base::colSums(obj@data)
Error in base::colSums(obj@data) : 
  'x' must be an array of at least two dimensions

Best,
Leon

OK and thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

camilliano picture camilliano  路  3Comments

igordot picture igordot  路  3Comments

sarahwajid picture sarahwajid  路  3Comments

farhanma picture farhanma  路  3Comments

rajasreemenon picture rajasreemenon  路  3Comments