You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dotplot / Matrixplot Bug/Suggestion [Key Error] Because "var_group_labels" & "categories_order" using the same variable (memory), mostly happened when "swap_axes=True"
#3081
Open
3 tasks done
WhatMelonGua opened this issue
May 31, 2024
· 1 comment
It cut off the string in functions dotplot/matrixplot(var_group_labels=) , as the function _plot_var_groups_brackets(group_labels=).
So, when we use code like the sample, the veryvery long labels will be cut off & we got an Error
Because Var celltype_order is a list, and function _plot_var_groups_brackets (PATH: scanpy/plotting/_baseplot_class.py) will affect the string in list,
then if affect the celltype_order itself, so
when called with the categories_order, it has been changed by _plot_var_groups_brackets, then the Error happened.
I suggest to add one copy, for parameter group_labels in function _plot_var_groups_brackets
It may help someone are not so skillful on coding, to solve the problem maybe happen.
For example: add the code group_labels = copy.deepcopy(group_labels) at the top of function _plot_var_groups_brackets
Please make sure these conditions are met
What happened?
In fact, that's not a real bug report, but a suggestion about safe design to plot with scanpy.
It may happen when our celltype name is too long to show in the plotting figure.
The problem happens here:
scanpy/scanpy/plotting/_baseplot_class.py
Lines 1059 to 1061 in a20334f
It cut off the string in functions
dotplot
/matrixplot(var_group_labels=)
, as the function_plot_var_groups_brackets(group_labels=)
.So, when we use code like the sample, the veryvery long labels will be cut off & we got an Error
Because Var
celltype_order
is a list, and function_plot_var_groups_brackets
(PATH: scanpy/plotting/_baseplot_class.py) will affect the string in list,then if affect the
celltype_order
itself, sowhen called with the
categories_order
, it has been changed by_plot_var_groups_brackets
, then the Error happened.I suggest to add one copy, for parameter
group_labels
in function_plot_var_groups_brackets
It may help someone are not so skillful on coding, to solve the problem maybe happen.
For example: add the code
group_labels = copy.deepcopy(group_labels)
at the top of function_plot_var_groups_brackets
Thank you very much for your attention
Minimal code sample
Error output
Versions
The text was updated successfully, but these errors were encountered: