dylkot / pyWNN

Weighted Nearest Neighbors Analysis implemented in Python (pyWNN)
MIT License
10 stars 2 forks source link

IndexError 'get_nearestneighbor' -> index 0 is out of bounds for axis 0 with size 0 #4

Closed deborahboyenval closed 2 weeks ago

deborahboyenval commented 2 weeks ago

Hi @dylkot,

Thanks for implementing this in python! Unfortunately I'm encountering an index error : IndexError 'get_nearestneighbor' -> index 0 is out of bounds for axis 0 with size 0 more specifically : ---> 20 nn_idx.append(cols[idx[neighbor-1]])

Here's some details:

The PCA for the protein modality: adata_ADT = mudata.mod["ADT"] sc.pp.pca(adata_ADT, n_comps=20) adata_ADT.obsm["X_pca"].shape adata_ADT is of the form: AnnData object with n_obs × n_vars = 9635 × 23 var: 'highly_variable' uns: 'pca' obsm: 'X_pca' varm: 'PCs' layers: 'counts', 'data'

Now the RNA modality (adata_RNA) and its PCA: adata_RNA = mudata.mod["RNA"] sc.pp.pca(adata_RNA, n_comps=20) adata_RNA.obsm["X_pca"].shape

adata_RNA is of the form: AnnData object with n_obs × n_vars = 9635 × 32285 obs: 'cellType', 'condition', 'sample_batch' uns: 'pca', 'cellType_colors', 'condition_colors' obsm: 'X_pca', 'X_wnn.umap', 'RNA_PCA', 'ADT_PCA' varm: 'PCs' layers: 'counts', 'data' X_wnn.umap comes from Seurat (but I want to switch to python). I did before : adata_RNA.obsm["RNA_PCA"] = adata_RNA.obsm["X_pca"] adata_RNA.obsm["ADT_PCA"] = adata_ADT.obsm["X_pca"]

Then : WNNobj = pyWNN(adata_RNA, reps=['RNA_PCA', 'ADT_PCA'], npcs=[30,18], n_neighbors=20, seed=14)

Do you have any idea of what the problem might be?

Thanks in advance, Déborah

UPDATE : II'll close the issue myself: basically sc.pp.neighbors(adata_ADT) and sc.pp.neighbors(adata_RNA) were missing !