f-hamidlab / nuclearpy

MIT License
0 stars 0 forks source link

show cells after leiden cluster #23

Closed Marcel-Salier closed 2 years ago

Marcel-Salier commented 2 years ago

I tried the cluster with higher LaminB1 and I got this:

KeyError Traceback (most recent call last) Input In [42], in <cell line: 1>() ----> 1 obj.showCells(RGB_contrasts=[4,3,4], n=5, ch2show={'red':'laminB1', 'green':'actin'}, filter = "leiden == '5'")

File ~/Documents/GitHub/ng_tools/ngtools/analyzer.py:735, in Analyzor.showCells(self, n, cells, ch2show, order_by, ascending, fig_height, fig_width, show_nucleus, RGB_contrasts, uniqID, filter) 733 obj = self.copy() 734 if type(filter) is str: --> 735 obj.filterCells(filter = filter) 737 show_cell(obj.data['raw'], order_by, fig_height, fig_width, show_nucleus, RGB_contrasts, uniqID, ch2show, n, 738 obj.meta['channels'], ascending, cells)

File ~/Documents/GitHub/ng_tools/ngtools/analyzer.py:902, in Analyzor.filterCells(self, filter, data_type, cells, inplace) 900 self.data['raw'] = self.data['raw'].loc[cells,] 901 self.data['norm'] = self.data['norm'].loc[cells,] --> 902 self.updateAData() 903 else: 904 dat = self.copy()

File ~/Documents/GitHub/ng_tools/ngtools/analyzer.py:524, in Analyzor.updateAData(self) 523 def updateAData(self): --> 524 self.buildAData(self.excfeat) 525 self.normAData()

File ~/Documents/GitHub/ng_tools/ngtools/analyzer.py:984, in Analyzor.buildAData(self, excluded_features) 982 dat_vars = self.data['norm'].copy() 983 dat_vars = dat_vars.select_dtypes(include=['float64', 'int64']) --> 984 dat_vars = dat_vars.drop(columns=to_drop) 986 # get obs data 987 dat_obs = self.data['norm'].copy()

File /opt/anaconda3/envs/ngtools/lib/python3.10/site-packages/pandas/util/_decorators.py:311, in deprecate_nonkeyword_arguments..decorate..wrapper(*args, *kwargs) 305 if len(args) > num_allow_args: 306 warnings.warn( 307 msg.format(arguments=arguments), 308 FutureWarning, 309 stacklevel=stacklevel, 310 ) --> 311 return func(args, **kwargs)

File /opt/anaconda3/envs/ngtools/lib/python3.10/site-packages/pandas/core/frame.py:4954, in DataFrame.drop(self, labels, axis, index, columns, level, inplace, errors) 4806 @deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "labels"]) 4807 def drop( 4808 self, (...) 4815 errors: str = "raise", 4816 ): 4817 """ 4818 Drop specified labels from rows or columns. 4819 (...) 4952 weight 1.0 0.8 4953 """ -> 4954 return super().drop( 4955 labels=labels, 4956 axis=axis, 4957 index=index, 4958 columns=columns, 4959 level=level, 4960 inplace=inplace, 4961 errors=errors, 4962 )

File /opt/anaconda3/envs/ngtools/lib/python3.10/site-packages/pandas/core/generic.py:4267, in NDFrame.drop(self, labels, axis, index, columns, level, inplace, errors) 4265 for axis, labels in axes.items(): 4266 if labels is not None: -> 4267 obj = obj._drop_axis(labels, axis, level=level, errors=errors) 4269 if inplace: 4270 self._update_inplace(obj)

File /opt/anaconda3/envs/ngtools/lib/python3.10/site-packages/pandas/core/generic.py:4311, in NDFrame._drop_axis(self, labels, axis, level, errors, consolidate, only_slice) 4309 new_axis = axis.drop(labels, level=level, errors=errors) 4310 else: -> 4311 new_axis = axis.drop(labels, errors=errors) 4312 indexer = axis.get_indexer(new_axis) 4314 # Case for non-unique axis 4315 else:

File /opt/anaconda3/envs/ngtools/lib/python3.10/site-packages/pandas/core/indexes/base.py:6644, in Index.drop(self, labels, errors) 6642 if mask.any(): 6643 if errors != "ignore": -> 6644 raise KeyError(f"{list(labels[mask])} not found in axis") 6645 indexer = indexer[~mask] 6646 return self.delete(indexer)

KeyError: "['leiden', 'umap_1', 'umap_2'] not found in axis"