scverse / muon

muon is a multimodal omics Python framework
https://muon.scverse.org/
BSD 3-Clause "New" or "Revised" License
218 stars 31 forks source link

ValueError: could not broadcast input array from shape #128

Open wariobrega opened 11 months ago

wariobrega commented 11 months ago

Hello,

I have a dataset made of unpaired RNA/ATAC seq data.

I performed PCA / nearest neighbors on each modality using a standard approach and I was going for the joint neighbors embedding.

I obtain however the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[/home/dcapocef/Projects/EPINet/scripts/screen_orig_data.ipynb](https://file+.vscode-resource.vscode-cdn.net/home/dcapocef/Projects/EPINet/scripts/screen_orig_data.ipynb) Cell 31 line 1
----> [1](vscode-notebook-cell:/home/dcapocef/Projects/EPINet/scripts/screen_orig_data.ipynb#X54sZmlsZQ%3D%3D?line=0) mu.pp.neighbors(ctrl)

File [~/miniconda3/envs/muon/lib/python3.10/site-packages/muon/_core/preproc.py:465](https://file+.vscode-resource.vscode-cdn.net/home/dcapocef/Projects/EPINet/scripts/~/miniconda3/envs/muon/lib/python3.10/site-packages/muon/_core/preproc.py:465), in neighbors(mdata, n_neighbors, n_bandwidth_neighbors, n_multineighbors, neighbor_keys, metric, low_memory, key_added, weight_key, add_weights_to_modalities, eps, copy, random_state)
    [463](https://file+.vscode-resource.vscode-cdn.net/home/dcapocef/Projects/EPINet/scripts/~/miniconda3/envs/muon/lib/python3.10/site-packages/muon/_core/preproc.py:463)         currtheta = theta
    [464](https://file+.vscode-resource.vscode-cdn.net/home/dcapocef/Projects/EPINet/scripts/~/miniconda3/envs/muon/lib/python3.10/site-packages/muon/_core/preproc.py:464)     else:
--> [465](https://file+.vscode-resource.vscode-cdn.net/home/dcapocef/Projects/EPINet/scripts/~/miniconda3/envs/muon/lib/python3.10/site-packages/muon/_core/preproc.py:465)         thetas[:, lasti] = theta
    [466](https://file+.vscode-resource.vscode-cdn.net/home/dcapocef/Projects/EPINet/scripts/~/miniconda3/envs/muon/lib/python3.10/site-packages/muon/_core/preproc.py:466)         lasti += 1
    [467](https://file+.vscode-resource.vscode-cdn.net/home/dcapocef/Projects/EPINet/scripts/~/miniconda3/envs/muon/lib/python3.10/site-packages/muon/_core/preproc.py:467) ratios[ratioidx, i1] = currtheta [/](https://file+.vscode-resource.vscode-cdn.net/) (np.max(thetas, axis=1) + eps)

ValueError: could not broadcast input array from shape (0,) into shape (5106,)

This usually happens after a couple of minutes after running the command, so way along the line

The data is made of 5106 Cells from ATAC and 4215 Cells from RNA.

I am using the latest stable version of muon on a conda environment running python 3.10. The conda env contains only muon and its minimal dependencies + ipython kernel/jupyter specs.

Can you help me understand this issue and how to fix it?

Thanks,

Daniele

jefferyUstc commented 3 months ago

Today I also encountered the same bug. Any fix now?

jefferyUstc commented 3 months ago

It seems that a little bit different from the above, this is the traceback info

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[675], line 1
----> 1 mu.pp.neighbors(mdata_cc, key_added='wnn', n_neighbors=15)
      2 mu.tl.umap(mdata_cc, neighbors_key='wnn', random_state=10)

File [/home/to/envs/scverse/lib/python3.10/site-packages/muon/_core/preproc.py:491](http://localhost:8989/home/to/envs/scverse/lib/python3.10/site-packages/muon/_core/preproc.py#line=490), in neighbors(mdata, n_neighbors, n_bandwidth_neighbors, n_multineighbors, neighbor_keys, metric, low_memory, key_added, weight_key, add_weights_to_modalities, eps, copy, random_state)
    489         currtheta = theta
    490     else:
--> 491         thetas[:, lasti] = theta
    492         lasti += 1
    493 ratios[ratioidx, i1] = currtheta [/](http://localhost:8989/) (np.max(thetas, axis=1) + eps)

ValueError: could not broadcast input array from shape (0,) into shape (13498,)
gtca commented 1 month ago

Hey @jefferyUstc, thanks for reporting this.

So far I wasn't able to reproduce this error. Is there any data that we could reproduce it on? Does it also happen with the latest version of muon from the main branch?