Repository navigation
Take feature_plot's quantile cutoffs as Seurat's SetQuantile does - #151
Merged
Merged
Conversation
min_cutoff="q05", max_cutoff="q95", the call the skills recommend for a washed-out colour scale, collapsed the colour bar of a gene detected in under 5% of cells to (0, 1e-9): every expressing cell the same colour and no sign anything was wrong. The committed SCTransform tutorial figure showed it, on XCL1. The issue read this as a documentation gap. Seurat:::SetQuantile on 5.5.1 shows it is a divergence: Seurat takes the percentile over the cells that express the feature (data[data > 0]), where feature_plot took it over every cell, so a sparse gene's 5th and 95th percentiles were both 0 and the same call works in R. The values are pinned to SetQuantile's own output, including negatives and an all-zero feature, which R returns NA for and this maps to 0. Only the strings "q05" and "q95" were recognised, and "q99" raised a TypeError from comparing a string with a float. Any q and one or two digits is accepted now, as in Seurat, and anything else is a ValueError. Cutoffs that still leave the scale no range (equal, inverted, or every expresser the same value) warn and draw the feature over its own range, as the issue asked. 03_sct_featureplots_1.png and 04_sct_featureplots_2.png are redrawn; the other four figures the script writes are identical to the pixel. The CITE-seq ADT panel does not change, since every cell has a positive CLR value there. Seven mutants each fail their own tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Fixes #145, though the cause is not the one the issue assumed.
The issue read the collapsed colour bar as a documentation gap: the skills recommend
min_cutoff="q05", max_cutoff="q95", and for a gene detected in under 5% of cells both quantiles are 0. That is true offeature_plot, but not of Seurat.Seurat:::SetQuantileon 5.5.1 takes the percentile over the cells that express the feature (data <- data[data > 0]), so the same call works in R.feature_plottook it over every cell. This is a port divergence, and I fixed it as one.What changed
_set_quantilemirrorsSetQuantile: anyqand one or two digits, over the values above zero, R's default percentile definition. The values are pinned intests/test_feature_plot_cutoffs.pyto whatSeurat:::SetQuantilereturns for the same vectors (q050.625,q9517.5, the sparse example 0.6 and 2.85, and so on). Negatives are left out, as in R. A feature nothing expresses gets 0, where R givesNA.qNNis accepted. The code recognised only the literal strings"q05"and"q95". Anything else fell through tovmin = "q99", and"q99"raised aTypeErrorcomparing a string with a float, which includes the"q99"the issue itself suggests as a workaround. Anything that is not a number orqNNis now aValueErrorthat says what is allowed.A committed tutorial figure showed this
tutorials/figures_sctransform/04_sct_featureplots_2.pnghadXCL1with a colour bar of0.0 ... 1.0 ×1e-9: every expressing cell one colour, andFCER2nearly binary. The caption says "matching the vignette". I regenerated that figure and03_sct_featureplots_1.png, and looked at both:XCL1now has a scale of about 0.7 to 1.35 with a visible gradient.main, which includes the group-order change in Draw groups in a categorical column's own order, so reorder_ident has an effect #149, and they are still byte-identical to the committed ones.frac > 0is 1.00 for all eight proteins), so the cells that express a protein are all of them and both rules give the same scale. R's panel already used these quantiles. I rendered it under both rules and the two images are byte-identical.This is the one change in the series that alters what an existing call draws, so it is worth your eye.
git revertis clean if you disagree.Verification
plotting.pyis down two (131), because the newfloat | str | Nonereplaced twoOptionalannotations. mypy is at its 4 baseline errors.No release is needed for this change on its own, though it changes how documented calls draw. The CHANGELOG entry is under
[Unreleased]→ Fixed.🤖 Generated with Claude Code