Closed rgoya closed 1 month ago
Hi, thanks for the report!
Note that the plots in the documentation are generated on the fly when building the documentation. The plot you currently see on https://scanpy.readthedocs.io/en/stable/generated/scanpy.pl.dotplot.html has therefore been created with scanpy 1.10.1
Must be a dependency issue, I’ll try to reproduce with the environment you provided.
/edit: I can reproduce it with that environment:
OK, pretty sure this is because your environment uses pandas 1.5
You can circumvent it for now by setting dp.categories_order = dp.dot_color_df.index
:
Thanks for the quick response, @flying-sheep!
I can confirm that updating pandas-2.2.2 does fix this. I totally missed this possibility; it's not clear to me why the dots would change ordering, but the totals wouldn't (maybe scanpy relies on default pandas behaviour that changed between 1.x and 2.x?). That said, pandas-2.x unfortunately breaks some dependencies in our environment, so I'll either pin scanpy or use your workaround.
Regarding the ordering and issue title change. Maybe a nit, but it's my understanding that the default ordering is alphabetical (which makese perfect sense as a default!). If this is correct, then I'd suggest that the wrong ordering is not the totals, but the categories themselves.
Given this, the workaround that gives me the expected behaviour would be dp.categories_order = dp.dot_color_df.index.sort_values()
:
Please make sure these conditions are met
What happened?
In
scanpy-1.9.8
DotPlots the default ordering of categories is alphabetical, adjusting to what was requested viagroupby
. This also worked when multiple columns were requested, eliminating the need to manually compose the alphabetical ordering of all existing combinations of observations in the plot.The default ordering in
scanpy>=1.10.0
DotPlots has changed, and resulting plots display wrong data:add_totals()
, the bar plots with cell counts do follow the default alphabetical ordering, making the plot display wrong data (!).The example below shows the misbehaviour using the example in https://scanpy.readthedocs.io/en/stable/generated/scanpy.pl.dotplot.html
Using the code example below; here is the expected plot with
scanpy-1.9.8
(same result as in the URL above):and here is the erroneous result with
scanpy-1.10.1
and1.10.0
(wrong ordering, mismatching totals):Minimal code sample
Error output
Versions