Plotting issue in python 3.9, multi_lut_set
for xclone.pl.Complex_BAF_CNV_visualization
.
#14
Labels
bug
Something isn't working
NotImplementedError Traceback (most recent call last)
Cell In[9], line 10
4 cell_anno_key_plot = ["testclone2", "spot_anno"]
7 clusters_display_name = ["testclone2", "spot_anno"]
---> 10 xclone.pl.Complex_BAF_CNV_visualization(adata, Xlayer = "posterior_mtx",
11 cell_anno_key = cell_anno_key_plot, clusters_display_name = clusters_display_name)
File ~/Github_repos/XClone/xclone/plot/CNV_plot.py:470, in Complex_BAF_CNV_visualization(Xdata, Xlayer, weights, states_weight, colorbar_name, cell_anno_key, clusters_display_name, **kwargs)
468 elif states_num == 5:
469 color_map = color_mapping(cm_name = "BAF_cmap1")
--> 470 XXheatmap(res_cnv_ad_re, cell_anno_key = cell_anno_key, clusters_display_name = clusters_display_name,
471 center = center_value,
472 colorbar_ticks = [0.3, 1, 1.9, 2.8, 3.5],
473 colorbar_name = colorbar_name,
474 colorbar_label = ["allele-A bias (++)", "allele-A bias (+)", "allele balance", "allele-B bias (+)", "allele-B bias (++)"],
475 cmap = color_map, **kwargs)
476 return None
File ~/Github_repos/XClone/xclone/plot/_base_xanndata.py:342, in XXheatmap(Xdata, Xlayer, cell_anno_key, clusters_display_name, sns_palette_lst, cell_legend_title, title, X_xlabel, X_ylabel, legend_pos, legend_mode, add_chr, change_colorbar, colorbar_ticks, colorbar_label, colorbar_name, save_file, set_dpi, out_file, **kwargs)
338 X_df = prepare_Xheatmap_df(Xdata, Xlayer)
340 ## _clusters for obs(rows) and _chrs for cols
341 ### obs
--> 342 row_colors, row_luts, lut_dic_lst = multi_lut_set(Xdata, cell_anno_key, clusters_display_name, sns_palette_lst)
344 ### vars
345 _chrs = X_df.columns
File ~/Github_repos/XClone/xclone/plot/_base_xanndata.py:290, in multi_lut_set(Xdata, cell_anno_key, clusters_display_name, sns_palette_lst)
288 lut_dic_lst.append(tmp_lut_copy) ## important
289 # https://www.kite.com/python/answers/how-to-append-a-dictionary-to-a-list-in-python
--> 290 tmp_row_colors = _clusters.map(tmp_lut)
291 # for add separate cell annotation legends
292 if idx == 0:
File ~/anaconda3/envs/xclone_dev/lib/python3.9/site-packages/pandas/core/series.py:4700, in Series.map(self, arg, na_action)
4620 def map(
4621 self,
4622 arg: Callable | Mapping | Series,
4623 na_action: Literal["ignore"] | None = None,
4624 ) -> Series:
4625 """
4626 Map values of Series according to an input mapping or function.
4627
(...)
4698 dtype: object
4699 """
-> 4700 new_values = self._map_values(arg, na_action=na_action)
4701 return self._constructor(new_values, index=self.index, copy=False).finalize(
4702 self, method="map"
4703 )
File ~/anaconda3/envs/xclone_dev/lib/python3.9/site-packages/pandas/core/base.py:919, in IndexOpsMixin._map_values(self, mapper, na_action, convert)
916 arr = self._values
918 if isinstance(arr, ExtensionArray):
--> 919 return arr.map(mapper, na_action=na_action)
921 return algorithms.map_array(arr, mapper, na_action=na_action, convert=convert)
File ~/anaconda3/envs/xclone_dev/lib/python3.9/site-packages/pandas/core/arrays/categorical.py:1565, in Categorical.map(self, mapper, na_action)
1562 if na_action is None and has_nans:
1563 na_val = mapper(np.nan) if callable(mapper) else mapper.get(np.nan, np.nan)
-> 1565 if new_categories.is_unique and not new_categories.hasnans and na_val is np.nan:
1566 new_dtype = CategoricalDtype(new_categories, ordered=self.ordered)
1567 return self.from_codes(self._codes.copy(), dtype=new_dtype, validate=False)
File properties.pyx:36, in pandas._libs.properties.CachedProperty.get()
File ~/anaconda3/envs/xclone_dev/lib/python3.9/site-packages/pandas/core/indexes/base.py:2840, in Index.hasnans(self)
2819 """
2820 Return True if there are any NaNs.
2821
(...)
2837 True
2838 """
2839 if self._can_hold_na:
-> 2840 return bool(self._isnan.any())
2841 else:
2842 return False
File properties.pyx:36, in pandas._libs.properties.CachedProperty.get()
File ~/anaconda3/envs/xclone_dev/lib/python3.9/site-packages/pandas/core/indexes/base.py:2810, in Index._isnan(self)
2806 """
2807 Return if each value is NaN.
2808 """
2809 if self.can_hold_na:
-> 2810 return isna(self)
2811 else:
2812 # shouldn't reach to this condition by checking hasnans beforehand
2813 values = np.empty(len(self), dtype=np.bool)
File ~/anaconda3/envs/xclone_dev/lib/python3.9/site-packages/pandas/core/dtypes/missing.py:178, in isna(obj)
101 def isna(obj: object) -> bool | npt.NDArray[np.bool_] | NDFrame:
102 """
103 Detect missing values for an array-like object.
104
(...)
176 Name: 1, dtype: bool
177 """
--> 178 return _isna(obj)
File ~/anaconda3/envs/xclone_dev/lib/python3.9/site-packages/pandas/core/dtypes/missing.py:203, in _isna(obj, inf_as_na)
201 return libmissing.checknull(obj, inf_as_na=inf_as_na)
202 elif isinstance(obj, ABCMultiIndex):
--> 203 raise NotImplementedError("isna is not defined for MultiIndex")
204 elif isinstance(obj, type):
205 return False
NotImplementedError: isna is not defined for MultiIndex
The text was updated successfully, but these errors were encountered: