atarashansky / SAMap

SAMap: Mapping single-cell RNA sequencing datasets from evolutionarily distant organisms.
MIT License
64 stars 19 forks source link

SAMAP object instantiation fails with AttributeError #112

Open carlosj-rr opened 1 year ago

carlosj-rr commented 1 year ago

Hello,

I am following the notebook for some of my analyses.

It all goes swimmingly (I've loaded SAM objects, as in the notebook), but when I instantiate the SAMAP() object in the line:

sm = SAMAP(sams, f_maps = 'path/to/maps/')

I get an AttributeError from numpy:

~/work/miniconda3/envs/SAMap/lib/python3.7/site-packages/samalg/__init__.py in calculate_nnm(self, adata, batch_key, g_weighted, n_genes, preprocessing, npcs, num_norm_avg, weight_PCs, sparse_pca, update_manifold, weight_mode, seed, components, first)
   1138                     v = adata.var['variances'].values[gkeep]
   1139                     v[v==0]=1
-> 1140                     Ds = Ds.multiply(1/v**0.5).tocsr()
   1141
   1142             else:

AttributeError: 'numpy.ndarray' object has no attribute 'multiply'

On first sight, it seemed like a bug since 'multiply' is indeed not an attribute of numpy arrays, but then I wondered that perhaps I was loading some data in the wrong format.

Could I add any more information to make my case clear?

Thanks a lot,

Carlos

atarashansky commented 1 year ago

Ahh, sorry, Carlos - the documentation is unclear with regards to what data SAMAP is expecting.

SAMAP expects the AnnData.X to be in sparse format (scipy.sparse matrix). Can you check if your data is dense or sparse?