STOmics / Stereopy

A toolkit of spatial transcriptomic analysis.
MIT License
180 stars 59 forks source link

ValueError: Length mismatch: Expected axis has 1 elements, new values have 261800 elements during data.tl.cell_cell_communication #208

Closed THZ34 closed 8 months ago

THZ34 commented 8 months ago

This error was happend in "data.index = self.stereo_exp_data.gene_names" of CellCellCommunication._prepare_data, cause of "data = pd.DataFrame(self.stereo_exp_data.exp_matrix.T)" the pd.DataFrame() could not create dataframe from csc_matrix. After "data = pd.DataFrame(self.stereo_exp_data.exp_matrix.T)", the data is looks like this: Out[19]: 0 0 (0, 4)\t73.171745\n (0, 11)\t11.9333\n (0,... 1 (0, 7)\t14.686208\n (0, 11)\t11.9333\n (0,... 2 (0, 10)\t16.280352\n (0, 11)\t11.9333\n (0... 3 (0, 2)\t50.327488\n (0, 7)\t14.686208\n (0... 4 (0, 6)\t84.74585\n (0, 22)\t27.901155\n (0... ... ... 1005 (0, 24)\t20.425388\n (0, 42)\t21.695843\n ... 1006 (0, 3)\t58.821655\n (0, 7)\t14.686208\n (0... 1007 (0, 153)\t33.00077\n (0, 250)\t31.556194\n ... 1008 (0, 24)\t20.425388\n (0, 70)\t26.589325\n ... 1009 (0, 1)\t66.0079\n (0, 47)\t44.394123\n (0,... [1010 rows x 1 columns]

A better way is use "data = pd.DataFrame(self.stereo_exp_data.exp_matrix.T.todense())"