Skip to content

Add layout option to coda plot_boxplots (#718)#932

Open
emekaokoli19 wants to merge 6 commits intoscverse:mainfrom
emekaokoli19:fix-plot_boxplots
Open

Add layout option to coda plot_boxplots (#718)#932
emekaokoli19 wants to merge 6 commits intoscverse:mainfrom
emekaokoli19:fix-plot_boxplots

Conversation

@emekaokoli19
Copy link

PR Checklist

  • Referenced issue is linked
  • If you've fixed a bug or added code that should be tested, add tests
  • Documentation in docs is updated

Description of changes

This PR adds a new layout parameter to plot_boxplots() in the Sccoda plotting utilities.

Currently, when plot_facets=True, the number of subplot columns is determined using:

col_wrap = int(np.floor(np.sqrt(K)))

where K is the number of cell types. This tends to produce a taller ("long") layout for the facet grid.

The new layout parameter allows users to choose between two layouts:

  • "long" (default): uses floor(sqrt(K)), producing a taller layout.
  • "wide": uses ceil(sqrt(K)), producing a wider layout.

Example usage:

sccoda.plot_boxplots(
    mdata,
    feature_name="condition",
    plot_facets=True,
    layout="wide"
)

The default behavior remains unchanged to preserve backward compatibility.

This resolves #718.


Technical details

When plot_facets=True, the column wrapping logic now depends on the layout argument:

  • "long"col_wrap = floor(sqrt(K))
  • "wide"col_wrap = ceil(sqrt(K))

Validation is added to ensure layout is either "long" or "wide".

The change only affects the FacetGrid layout logic and does not impact any other functionality.


Additional context

This change improves flexibility for users visualizing many cell types, where a wider layout may be preferable for readability.

@codecov-commenter
Copy link

codecov-commenter commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.94%. Comparing base (12897e1) to head (41155c6).
⚠️ Report is 41 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #932      +/-   ##
==========================================
- Coverage   73.54%   71.94%   -1.60%     
==========================================
  Files          48       48              
  Lines        5613     5746     +133     
==========================================
+ Hits         4128     4134       +6     
- Misses       1485     1612     +127     
Files with missing lines Coverage Δ
pertpy/tools/_cinemaot.py 59.23% <100.00%> (ø)
pertpy/tools/_coda/_base_coda.py 57.64% <100.00%> (+0.47%) ⬆️
pertpy/tools/_coda/_tasccoda.py 72.90% <100.00%> (ø)
pertpy/tools/_milo.py 63.50% <100.00%> (-17.16%) ⬇️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

pre-commit-ci bot and others added 4 commits March 10, 2026 11:57
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.15.2 → v0.15.4](astral-sh/ruff-pre-commit@v0.15.2...v0.15.4)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* fix CI

Signed-off-by: Lukas Heumos <lukas.heumos@posteo.net>

* fix CI

Signed-off-by: Lukas Heumos <lukas.heumos@posteo.net>

---------

Signed-off-by: Lukas Heumos <lukas.heumos@posteo.net>
updates:
- [github.com/biomejs/pre-commit: v2.4.4 → v2.4.6](biomejs/pre-commit@v2.4.4...v2.4.6)
- [github.com/astral-sh/ruff-pre-commit: v0.15.4 → v0.15.5](astral-sh/ruff-pre-commit@v0.15.4...v0.15.5)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: Lukas Heumos <lukas.heumos@posteo.net>
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.

Suggestion for a better layout of coda plot_boxplots() subplots

3 participants