theislab / scgen

Single cell perturbation prediction
https://scgen.readthedocs.io
GNU General Public License v3.0
260 stars 52 forks source link

to_latent problem #8

Closed mxposed closed 5 years ago

mxposed commented 5 years ago

Hi! I tried to use to_latent method on the trained model and got the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-18-38e7b4c7913b> in <module>
----> 1 sc18z = network.to_latent(sc18)

~/.local/lib/python3.6/site-packages/scgen/models/_vae.py in to_latent(self, data)
    175                     Returns array containing latent space encoding of 'data'
    176         """
--> 177         latent = self.sess.run(self.z_mean, feed_dict={self.x: data, self.size: data.shape[0], self.is_training: False})
    178         return latent
    179 

~/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
    948     try:
    949       result = self._run(None, fetches, feed_dict, options_ptr,
--> 950                          run_metadata_ptr)
    951       if run_metadata:
    952         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

~/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
   1140             feed_handles[subfeed_t] = subfeed_val
   1141           else:
-> 1142             np_val = np.asarray(subfeed_val, dtype=subfeed_dtype)
   1143 
   1144           if (not is_tensor_handle_feed and

~/.local/lib/python3.6/site-packages/numpy/core/numeric.py in asarray(a, dtype, order)
    536 
    537     """
--> 538     return array(a, dtype, copy=False, order=order)
    539 
    540 

ValueError: setting an array element with a sequence.

What am I doing wrong?

I'm using pip scgen=1.1.1

Naghipourfar commented 5 years ago

Hi.

Thanks for the report. Can you say what is the type of sc18 variable. Is it in sparse format?

Best, Mohsen

chenxofhit commented 5 years ago

@Naghipourfar what is your email, I would like to ask you a few questions alone. I noticed you are active here in an hour before. @mxposed Forgive me to attach unrelated statement here.

Naghipourfar commented 5 years ago

.

chenxofhit commented 5 years ago

@Naghipourfar I have sent you emails, please check them. Thank you very much.

mxposed commented 5 years ago

@Naghipourfar yes, I tried Anndata object and it's sparse data, like sc18.X. Now I found that I should use sc18.X.A and it worked. I think you should add it to the documentation. Thank you