atarashansky / SAMap

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

Calculate Mapping Scores with leiden_clusters #55

Closed kmmika closed 3 years ago

kmmika commented 3 years ago

Hello again! I am trying to calculate mapping scores using leiden_clusters and keep getting the following error. I get the same error when I set both zf and mm to 'leiden_clusters'. Everything works fine if I use batch or cell type instead of leiden_clusters. I have tried creating a whole new column with a different dtype to see if that solved the issue and get a KeyError instead. Any help is appreciated, thanks!

keys = {'zf':'leiden_clusters','mm':'cell_type'} D,MappingTable = get_mapping_scores(sm,keys,n_top = 100)


TypeError Traceback (most recent call last)

in 1 keys = {'zf':'leiden_clusters','mm':'cell_type'} ----> 2 D,MappingTable = get_mapping_scores(sm,keys,n_top = 100) /usr/local/anaconda3/lib/python3.8/site-packages/samap/analysis.py in get_mapping_scores(sm, keys, n_top) 1563 1564 for sid in skeys: -> 1565 clusters.append(q([sid+'_'+x for x in sm.sams[sid].adata.obs[keys[sid]]])) 1566 1567 cl = np.concatenate(clusters) /usr/local/anaconda3/lib/python3.8/site-packages/samap/analysis.py in (.0) 1563 1564 for sid in skeys: -> 1565 clusters.append(q([sid+'_'+x for x in sm.sams[sid].adata.obs[keys[sid]]])) 1566 1567 cl = np.concatenate(clusters) TypeError: can only concatenate str (not "int") to str
atarashansky commented 3 years ago

I’m so grateful to you for helping me find these bugs lol. I should fix this in the code itself but apparently it expects the labels to be strings.

here’s a hot fix you can do in the meantime:

a=‘zf’ sm.sams[a].adata.obs[‘leiden_clusters’] = sm.sams[a].adata.obs[‘leiden_clusters’].astype(‘str’)

let me know if that works. It just converts the labels into strings

kmmika commented 3 years ago

Happy to help, lol. Thank you so much for responding so quickly!! That worked perfectly.

atarashansky commented 3 years ago

Fixed in v0.3.2!