dpeerlab / spectra

Supervised Pathway DEConvolution of InTerpretable Gene ProgRAms
MIT License
134 stars 17 forks source link

Key Error for est_spectra #2

Closed KarolineHoller closed 1 year ago

KarolineHoller commented 1 year ago

Hi, I used the data in the dropbox link from the Bassez publication, loaded with the respective scanpy method (note: the same function from the AnnData package did not work) and ran est_spectra with the cell_type_key = "Bassez_cellType". (This obs contains cell type annotations, like 'B_cell').

I get a KeyError that hints to line 1196 of spectra.py: for ct in gene_set_dictionary.keys(): 1195 new_gs_dict[ct] = {} -> 1196 mval = max(L[ct] - 1, 0) 1197 sorted_init_scores = sorted(init_scores[ct].items(), key=lambda x:x[1]) 1198 sorted_init_scores = sorted_init_scores[-1*mval:]

KeyError: 'B_cell'

Hope this helps!

wallet-maker commented 1 year ago

Hi,

please excuse the delayed response. Bassez_celltype is the wrong adata.obs key and results in mismatches with the default gene set annotation dictionary. I think this is the most likely reason for the error you are getting.

We realized that our tutorial did not provide sufficient detail and we have now expanded this:

https://github.com/dpeerlab/spectra/blob/main/notebooks/example_notebook.ipynb

We have also included the example data in the package with only one set of annotations to avoid confusion. Also, we provide guidance how to make sure your gene set annotation dictionary is formatted correctly.

Let me know if that helps.

Thanks, Thomas