earmingol / cell2cell

User-friendly tool to infer cell-cell interactions and communication from gene expression of interacting proteins
BSD 3-Clause "New" or "Revised" License
56 stars 12 forks source link

`c2c.io.read_data.load_tensor` loads NoneType #48

Closed paupaiz closed 6 months ago

paupaiz commented 11 months ago

Tensor output of c2c.analysis.run_tensor_cell2cell_pipeline works fine but loading it from the .pkl file doesn't Can reproduce this error in the package's colab demo.

Screenshot 2023-12-22 at 6 05 59 PM
earmingol commented 11 months ago

It looks like you are loading the tensor properly since it prints the InteractionTensor object. However, you get Nonetype for the tensor.factors and tensor.rank, which means you haven't run the decomposition on that object.

It could be because you are saving the tensor before running the decomposition.

earmingol commented 11 months ago

Just checked the google collab and yes, the tensor you are saving is the one without running the decomposition (tensor). The one to save should be the variable tensor2, which includes the outputs of running the pipeline. This happens because in that case we are passing the copy_tensor=True parameter, so the pipeline does not modify the original tensor and outputs a new one instead.

I have now modified the collab to save tensor2 instead. That is, modifying this: c2c.io.export_variable_with_pickle(tensor, output_folder + 'Tensor.pkl') to c2c.io.export_variable_with_pickle(tensor2, output_folder + 'Tensor.pkl')