scFEA icon indicating copy to clipboard operation
scFEA copied to clipboard

TypeError: can't convert np.ndarray of type numpy.object_. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.

Open QianChwnLyn opened this issue 2 years ago • 3 comments

Hi, I met a wrong when I run the mouse data. My input data is in .csv format. When it runs into this step, occurred some wrongs.

Starting load data... Calculating MAGIC... Running MAGIC on 51914 cells and 22382 genes. Calculating graph and diffusion operator... Calculating PCA... Calculated PCA in 39.08 seconds. Calculating KNN search... Calculated KNN search in 493.08 seconds. Calculating affinities... Calculated affinities in 490.14 seconds. Calculated graph and diffusion operator in 1027.61 seconds. Running MAGIC with solver='exact' on 22382-dimensional data may take a long time. Consider denoising specific genes with genes=<list-like> or using solver='approximate'. Calculating imputation... Calculated imputation in 104.30 seconds. Calculated MAGIC in 1135.44 seconds.

Traceback (most recent call last): File "scFEA/./src/scFEA.py", line 370, in main(args) File "scFEA/./src/scFEA.py", line 140, in main cmMat = torch.FloatTensor(cmMat).to(device) TypeError: can't convert np.ndarray of type numpy.object. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool._

Please help me! Thanks.

QianChwnLyn avatar Sep 01 '22 02:09 QianChwnLyn

I met same problem but in

X = geneExprDf.values.T
X = torch.FloatTensor(X).

Change code to:

X = geneExprDf.values.T.astype(np.float32)
X = torch.FloatTensor(X).

can solve the problem

jiawei-zhong avatar Mar 25 '23 08:03 jiawei-zhong

Maybe the problem comes from the expression matrix, I title the header of the gene name column with "index", and it runs well.

chenyixid avatar Apr 27 '23 03:04 chenyixid

I encountered this error when I wrongly inputted the mouse module files like the parameter of stoichiometry_matrix or module gene file, to the calculation of human transcriptomes. So you may check this to see whether it is the reason, i.e., unmatched gene symbols

LiuCanidk avatar Apr 11 '24 15:04 LiuCanidk