ValueError: setting an array element with a sequence- Anndata object

90 Views Asked by At

I have an anndata object, and I am trying to reassign the raw counts to the X layer of the anndata object using this code: adata2.X = adata2.layers['counts'].copy() adata2.X

However, I receive these errors, TypeError: float() argument must be a string or a number, not 'csr_matrix' ValueError: setting an array element with a sequence.

When I checked the counts and X layers, the counts layer was a sparse matrix (<27132x14167 sparse matrix of type '<class 'numpy.float64'>' with 37469551 stored elements in Compressed Sparse Row format>) and the X layer was an array (ArrayView). I also inspected the shape of the layers and both are (27132, 14167). I am not sure what is causing this error.

0

There are 0 best solutions below