Repository navigation
Feature: pl.ann_hist - #42
Merged
Merged
Conversation
Histogram of .obs/.var annotation columns, a thin wrapper around seaborn.histplot. level_key reduces repeated higher-level annotations (e.g. protein q-values on peptide-level data) to one value per group and asserts consistency within each group. vline/hline add reference lines with an optional legend. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d21ba48fdd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Annotations in
.obs/.varoften belong to a higher level than theaxis. A protein q-value, for example, is repeated on every peptide of
the protein in peptide-level data, so a plain histogram counts each
protein once per peptide.
pr.pl.ann_hist()plots any.obs/.varannotation (int, float, str, object or categorical) as a histogram.
With
level_key, it first reduces the data to one value per level andchecks that the value is constant within each level.
Related issues
None
General checklist
HISTORY.mdupdated under[Unreleased](errors only) are clean and the full suite passes (560 tests). CI
has not run yet.
✨ Feature
What it adds:
pr.pl.ann_hist(), a thin wrapper aroundseaborn.histplot.All extra kwargs are passed to
histplotunchanged.x/yname annotation columns and keep theirhistplotmeaning:one of them gives a univariate histogram, both give a bivariate one.
hueandweights, when given as strings, are read as columns too.level_key(str or list) keeps one row per group. It raises aValueErrorlisting example groups if a plotted column varies withina group.
axis("obs"/"var") is inferred whenNone. It raises if acolumn exists in both
.obsand.var, or if the columns come fromdifferent axes. Passing
axisresolves the first case.vline/hlinetake a dict or a list of dicts with the keysvalue,color(default"red"),linestyle(default"dashed")and
text. They draw full-span reference lines, and lines withtextget a legend to the right of the plot.zero_to_na/fill_naapply to the extractedx/yvalues.fill_naalso accepts a string label for categorical data.for categorical columns, otherwise lexicographic.
Example usage:
axisnot implemented yet; passing it raises
TypeError.checked behaviour by hand with a scratch script covering
level_key, the consistency check, axis resolution, ordering,fill_na/zero_to_na,vline/hline,saveand reservedkwargs. Unit tests should follow, including the two ordering tests
from AGENTS.md rule 4.
pr.load.toy_simple_peptides(), which does not exist onmainyet.pl.rst, Metadata exploration)Review attention:
_collapse_to_level(): the consistency check usesgroupby(...).nunique(dropna=False), so NaN counts as a distinctvalue.
_draw_lines(): callingax.legend()replaces seaborn'shuelegend, so the old legend is re-attached with
ax.add_artist.saveusesbbox_inches="tight"so the legend outside the axes isnot clipped.
sns.distplotwas considered as the backend but not used, becauseit is deprecated and handles numeric data only.
🤖 Generated with Claude Code