nealpsmith / neals_python_functions

Random useful python functions
MIT License
0 stars 1 forks source link

Bug that comes up when using a different name for "de_res" #11

Open RachellyN opened 3 years ago

RachellyN commented 3 years ago

When I run the functions "np.analysis.cellbrowser.make_kamil_browser" with a var_info parameter that is different than the default "de_res" I get the error below. This error is cause because in line 278 in the file neals_python_functions/analysis/cellbrowser.py, during the call to the function _make_cell_browser_files, the variable var_info is not being past. Therefore in _make_cell_browser_files function the default parameter is taken. In my case the anndata didn't include a varm object named "de_res" and so I got an error. I have fixed this by "var_info=var_info" to line 278.

Note that it might be safer to not have default values for parameters in inner functions. Just a suggestion.

The error:


Traceback (most recent call last): File "", line 1, in File "", line 28, in CellBrowser_wrapper File "/home/rnormand/.conda/envs/CellBrowser/lib/python3.7/site-packages/neals_python_functions/analysis/cellbrowser.py", line 230, in make_kamil_browser pval_precision, round_float) File "/home/rnormand/.conda/envs/CellBrowser/lib/python3.7/site-packages/neals_python_functions/analysis/cellbrowser.py", line 281, in prepare_cb_files pval_precision=pval_precision, round_float=round_float) File "/home/rnormand/.conda/envs/CellBrowser/lib/python3.7/site-packages/neals_python_functions/analysis/cellbrowser.py", line 54, in _make_cell_browser_files pval_precision, round_float) File "/home/rnormand/.conda/envs/CellBrowser/lib/python3.7/site-packages/neals_python_functions/analysis/cellbrowser.py", line 183, in _filter_de df_dict[var] = adata.varm[var_info]["{clust}:{var}".format(var=var, clust=clust)] File "/home/rnormand/.conda/envs/CellBrowser/lib/python3.7/site-packages/anndata/_core/aligned_mapping.py", line 148, in getitem return self._data[key] KeyError: 'de_res'