Skip to content

feat(plotting): add min_cells to DotPlot to drop sparse groupby categories - #4363

Open
micheleoliveiracod wants to merge 2 commits into
scverse:mainfrom
micheleoliveiracod:feat/min-cells-dotplot
Open

micheleoliveiracod wants to merge 2 commits into
scverse:mainfrom
micheleoliveiracod:feat/min-cells-dotplot

Conversation

@micheleoliveiracod

Copy link
Copy Markdown

Adds a min_cells parameter to BasePlot, DotPlot, and pl.dotplot that
drops groupby categories with fewer than the given number of cells before
plotting. This avoids showing summary statistics (fraction of nonzero
expressors, mean expression) for sparsely populated groups, which are not
very robust.

Matching categories are silently removed (unused categories are cleaned up
on the index), a ValueError is raised if no category meets the threshold,
and categories_order (when given) is filtered to match.

micheleoliveiracod and others added 2 commits September 12, 2026 16:17
…egories

Add a `min_cells` parameter to `BasePlot`, `DotPlot`, and `pl.dotplot`
that drops `groupby` categories with fewer than the given number of
cells before plotting. Categories are silently removed (with unused
categories cleaned up on the index), and a `ValueError` is raised if
no category meets the threshold. `categories_order`, when given, is
filtered to match.

Add tests covering the new parameter and its edge cases.

Co-Authored-By: Michele Oliveira <data.analystmlso@gmail.com>
@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.94%. Comparing base (5f2accb) to head (96344c0).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##           main    #4363       +/-   ##
=========================================
+ Coverage      0   81.94%   +81.94%     
=========================================
  Files         0      134      +134     
  Lines         0    13038    +13038     
=========================================
+ Hits          0    10684    +10684     
- Misses        0     2354     +2354     
Flag Coverage Δ
hatch-test.low-vers 78.82% <100.00%> (?)
hatch-test.pre 81.81% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/scanpy/plotting/legacy/_baseplot_class.py 81.11% <100.00%> (ø)
src/scanpy/plotting/legacy/_dotplot.py 91.89% <ø> (ø)

... and 132 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minimum cell cutoff in sc.pl.dotplot

1 participant