Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script_diffusion_umap problem #8

Open
chengfengke opened this issue Jul 2, 2024 · 5 comments
Open

script_diffusion_umap problem #8

chengfengke opened this issue Jul 2, 2024 · 5 comments

Comments

@chengfengke
Copy link

excuse me,i would like to know why I got ---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[8], line 6
3 adata_w.var_names = gene_names
5 autoencoder = load_VAE()
----> 6 cell_w = autoencoder(torch.tensor(adata_w.X).cuda(),return_latent=True).detach().cpu().numpy()
8 # concat this cell_w with cell_gen and send them to the autoencoder
9 cell_gen_all = autoencoder(torch.tensor(np.concatenate((cell_gen,cell_w),axis=0)).cuda(),return_decoded=True).cpu().detach().numpy()

File ~/anaconda3/envs/scDiffusion/lib/python3.9/site-packages/scipy/sparse/_base.py:404, in _spbase.len(self)
403 def len(self):
--> 404 raise TypeError("sparse array length is ambiguous; use getnnz()"
405 " or shape[0]")

TypeError: sparse array length is ambiguous; use getnnz() or shape[0] when I executing

if not generated all type of cells, use the real cell to balance the batchnorm in the scimilarity

adata_w = adata.copy()[::5]
adata_w.var_names = gene_names

autoencoder = load_VAE()
cell_w = autoencoder(torch.tensor(adata_w.X).cuda(),return_latent=True).detach().cpu().numpy()

concat this cell_w with cell_gen and send them to the autoencoder

cell_gen_all = autoencoder(torch.tensor(np.concatenate((cell_gen,cell_w),axis=0)).cuda(),return_decoded=True).cpu().detach().numpy()
cell_w.shape
this part of code, and I got different output with your previous results,cell_gen.shape=(600, 18996),not (12000,18996)

@chengfengke
Copy link
Author

is this a problem of the version of scipy?

@EperLuo
Copy link
Owner

EperLuo commented Jul 3, 2024

Hi! Thank you for raising this issue. We did find a small problem with the code here. The adata_w.X is a spare matrix, not a numpy array, so the right way is:

# if not generated all type of cells, use the real cell to balance the batchnorm in the scimilarity
adata_w = adata.copy()[::5]
adata_w.var_names = gene_names

autoencoder = load_VAE()
cell_w = autoencoder(torch.tensor(adata_w.X.toarray()).cuda(),return_latent=True).detach().cpu().numpy()

We will update this part of the code after we finish the revision.

@chengfengke
Copy link
Author

thank for your quick reply, I will try it.

@chengfengke
Copy link
Author

image I am not sure if it's right? and data.X is an array so it can not use to array(),and the two metrics can not alignment.

@JeanRadig
Copy link

Hi chengfengke,

In case you still have this issue, you can look at the fork I have created to reproduce the results of the paper: https://github.com/JeanRadig/scDiffusion.git.

Under Jean_Instructions you will find two notebooks that should be able to yield the plotting you are trying to get. Hope this helps :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants