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?
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.
Most helpful comment
Hi,
You can use the
base::colSums()function if your data is of classdata.frame. However, Seurat stores the normalised data as a sparse matrix (of classdgCMatrix), in which case thebase::colSums()function returns an error:Best,
Leon