atarashansky / SAMap

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

AttributeError after creating SAMAP object #124

Closed colinshew closed 10 months ago

colinshew commented 10 months ago

Hi, I'm having an issue where the SAMAP object is created without error but seems to be incomplete.

sm = SAMAP(filenames, f_maps='maps/')
Processing data Bf from:
bf_processed-merged.fix.h5ad
RUNNING SAM
Iteration: 0, Convergence: 1.0
Iteration: 1, Convergence: 0.8185823941319791
Iteration: 2, Convergence: 0.03471146673392333
Computing the UMAP embedding...
Elapsed time: 440.5178737640381 seconds
Not updating the manifold...
Processing data Mm from:
mm_pijuan-sala.h5ad
RUNNING SAM
Iteration: 0, Convergence: 1.0
Iteration: 1, Convergence: 0.8812113103232017
Computing the UMAP embedding...
Elapsed time: 390.509724855423 seconds
Not updating the manifold...
17974 `Bf` gene symbols match between the datasets and the BLAST graph.
17757 `Mm` gene symbols match between the datasets and the BLAST graph.

I keep getting attribute errors while trying to run downstream analyses. For example, there is no attribute 'gnnm_refined':

sm.query_gene_pairs('Bf_bf-00014594')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[14], line 2
      1 # Brachyury1
----> 2 sm.query_gene_pairs('bf-00014594')

File ~/mambaforge/envs/SAMap/lib/python3.9/site-packages/samap/mapping.py:518, in SAMAP.query_gene_pairs(self, gene)
    515     raise ValueError(f"Query gene {gene} not found in dataset.")
    517 a = self.gnnm[self.gns==qgene]
--> 518 b = self.gnnm_refined[self.gns==qgene]
    520 i1 = self.gns[a.nonzero()[1]]
    521 i2 = self.gns[b.nonzero()[1]]

AttributeError: 'SAMAP' object has no attribute 'gnnm_refined'

Upstream 'GNNMS_corr' also doesn't exist:

sm.GNNMS_corr
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[18], line 1
----> 1 sm.GNNMS_corr

AttributeError: 'SAMAP' object has no attribute 'GNNMS_corr'

Same with 'samap':

D,MappingTable = get_mapping_scores(sm,keys,n_top = 0)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[16], line 2
      1 keys = {'Bf':'leiden_new', 'Mm':'celltype'}
----> 2 D,MappingTable = get_mapping_scores(sm,keys,n_top = 0)
      4 D.head()

File ~/mambaforge/envs/SAMap/lib/python3.9/site-packages/samap/analysis.py:1528, in get_mapping_scores(sm, keys, n_top)
   1526     samap = SAM(counts = sm.samap.adata[np.in1d(sm.samap.adata.obs['species'],list(keys.keys()))])
   1527 else:
-> 1528     samap=sm.samap
   1530 clusters = []
   1531 ix = np.unique(samap.adata.obs['species'],return_index=True)[1]

AttributeError: 'SAMAP' object has no attribute 'samap'

The SAMs (sm.sams do exist). Any idea what is going wrong here? Thanks.

atarashansky commented 10 months ago

Hi - you initialized the SAMAP object but didn't run anything. Check out the tutorial notebook for an example on how to run it!

colinshew commented 9 months ago

Sorry, easy fix. Thanks for your quick reply! Missed that line under the section for starting from SAMs.