Skip to content

Commit

Permalink
Fix categories_order for class backed plots
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed Sep 20, 2024
1 parent e27e257 commit b8accc6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/scanpy/plotting/_dotplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ def dotplot(
use_raw: bool | None = None,
log: bool = False,
num_categories: int = 7,
categories_order: Sequence[str] | None = None,
expression_cutoff: float = 0.0,
mean_only_expressed: bool = False,
cmap: str = "Reds",
Expand Down Expand Up @@ -1024,6 +1025,7 @@ def dotplot(
use_raw=use_raw,
log=log,
num_categories=num_categories,
categories_order=categories_order,
expression_cutoff=expression_cutoff,
mean_only_expressed=mean_only_expressed,
standard_scale=standard_scale,
Expand Down
4 changes: 3 additions & 1 deletion src/scanpy/plotting/_matrixplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def __init__(
var_group_labels: Sequence[str] | None = None,
var_group_rotation: float | None = None,
layer: str | None = None,
standard_scale: Literal["var", "group"] = None,
standard_scale: Literal["var", "group"] | None = None,
ax: _AxesSubplot | None = None,
values_df: pd.DataFrame | None = None,
vmin: float | None = None,
Expand Down Expand Up @@ -343,6 +343,7 @@ def matrixplot(
use_raw: bool | None = None,
log: bool = False,
num_categories: int = 7,
categories_order: Sequence[str] | None = None,
figsize: tuple[float, float] | None = None,
dendrogram: bool | str = False,
title: str | None = None,
Expand Down Expand Up @@ -436,6 +437,7 @@ def matrixplot(
use_raw=use_raw,
log=log,
num_categories=num_categories,
categories_order=categories_order,
standard_scale=standard_scale,
title=title,
figsize=figsize,
Expand Down
13 changes: 11 additions & 2 deletions src/scanpy/plotting/_stacked_violin.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ def stacked_violin(
size: int = StackedViolin.DEFAULT_JITTER_SIZE,
density_norm: DensityNorm = StackedViolin.DEFAULT_DENSITY_NORM,
yticklabels: bool | None = StackedViolin.DEFAULT_PLOT_YTICKLABELS,
order: Sequence[str] | None = None,
categories_order: Sequence[str] | None = None,
swap_axes: bool = False,
show: bool | None = None,
save: bool | str | None = None,
Expand All @@ -707,6 +707,7 @@ def stacked_violin(
vcenter: float | None = None,
norm: Normalize | None = None,
# deprecated
order: Sequence[str] | None | Empty = _empty,
scale: DensityNorm | Empty = _empty,
**kwds,
) -> StackedViolin | dict | None:
Expand Down Expand Up @@ -735,7 +736,7 @@ def stacked_violin(
See :func:`~seaborn.stripplot`.
size
Size of the jitter points.
order
categories_order
Order in which to show the categories. Note: if `dendrogram=True`
the categories order will be given by the dendrogram and `order`
will be ignored.
Expand Down Expand Up @@ -809,6 +810,13 @@ def stacked_violin(
print(axes_dict)
"""
if order is not _empty:
msg = (
"`order` is deprecated (and never worked for `stacked_violin`), "
"use categories_order instead"
)
warnings.warn(msg, FutureWarning)
# no reason to set `categories_order` here, as `order` never worked.

vp = StackedViolin(
adata,
Expand All @@ -817,6 +825,7 @@ def stacked_violin(
use_raw=use_raw,
log=log,
num_categories=num_categories,
categories_order=categories_order,
standard_scale=standard_scale,
title=title,
figsize=figsize,
Expand Down

0 comments on commit b8accc6

Please sign in to comment.