SAMap icon indicating copy to clipboard operation
SAMap copied to clipboard

SAMAP object instantiation fails with AttributeError

Open carlosj-rr opened this issue 2 years ago • 1 comments

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

carlosj-rr avatar Apr 17 '23 11:04 carlosj-rr

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?

atarashansky avatar Apr 19 '23 15:04 atarashansky