Open reemagit opened 9 months ago
Thanks for spotting this! I'll keep this fix in mind if we ever release a new version of this package. The actively maintained implementation of scCODA in the pertpy package already contains a very similar fix.
I didn't know about the pertpy package, I'll check it out, thanks for letting me know. Not sure if I should close the issue or leave it open?
I'll leave it open for now, so that I won't forget about this fix. Thanks again!
Hello,
I think I found a bug in the
viz.boxplots
function, and also applied a solution that worked. Explaining it here in case other people ever ran into this problem.I have a cell counts AnnData object where each row is a subject and each column are the cell counts for that subject. For each subjects I have several categorical features such as
Smoke
that can assume three values andDisease
that assumes two values.I first plot
This works. Then, I plot
which also works. However, if I plot the feature "Disease" again, it crashes with the following error:
Note that this behavior is not easy to reproduce since I think it depends on how many categories each feature has. Moreover, when plotting other features, I found that the legend contained the levels of the previous feature "Smoke". This means that some global variables are persisting between function calls and are leaking in subsequent calls. I think I reconstructed why this happens. In the
data_visualization.py
script, the function signature of theboxplots
function is defined asThis function signature defines the default arguments of
args_boxplot
andargs_swamplot
as empty dicts ({}
). Using mutable default values is generally not recommended in python because it causes unexpected behaviors between function calls (see here). To avoid this behavior, I just replaced the default values withNone
and filled them within the function:and inside the function we add
Not sure if other functions use mutable default values. Thought it could be useful if other people ever ran into this problem.