MetaDraw: Add Score and Intensity coloration modes to BioPolymerCoverage View#2684
Open
nbollis wants to merge 9 commits into
Open
MetaDraw: Add Score and Intensity coloration modes to BioPolymerCoverage View#2684nbollis wants to merge 9 commits into
nbollis wants to merge 9 commits into
Conversation
Adds two new ColorResultsBy modes — PrecursorIntensity and Score — that color peptide rectangles using a 20-bin viridis scale normalized to the min/max of the current protein group. Includes a gradient bar in the legend with the metric name and actual value range.
14 new tests covering ViridisColors initialization, GetIntensityBrush mapping (bounds, mid, clamping), ColorBy setter for new modes, CreateLegendItems early return, and integration plotting with PrecursorIntensity and Score (including null, varying, and equal values).
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2684 +/- ##
==========================================
+ Coverage 93.29% 93.31% +0.01%
==========================================
Files 196 205 +9
Lines 21320 21438 +118
Branches 3994 4014 +20
==========================================
+ Hits 19891 20005 +114
Misses 893 893
- Partials 536 540 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
… normalization When every filtered result has null PrecursorIntensity in PrecursorIntensity mode, fall back to Score to derive a meaningful min/max/range instead of showing '0 - 0' on the gradient bar. Adds test coverage for this path.
zhuoxinshi
previously approved these changes
Jul 14, 2026
RayMSMS
previously approved these changes
Jul 14, 2026
Introduces a small OO color-mapping module under BioPolymerCoverage: - ColorGradientType enum (Viridis) - ColorGradient abstract base - ViridisColorGradient owning the 20-bin palette - ColorGradientFactory for gradient resolution 12 new tests cover gradient initialization, brush mapping, clamping, and factory dispatch. Existing BioPolymerCoverageMapViewModel behavior unchanged at this step.
Implements the color-mapping Strategy + Template Method design: - BioPolymerCoverageColorScale value object (MinValue/MaxValue/Range/Gradient/Normalize) - BioPolymerCoverageColorMapper abstract base (ColorBy/IsNumeric/GetBrush) - CategoricalBioPolymerCoverageColorMapper (Func selector strategy) - NumericBioPolymerCoverageColorMapper (Template Method: subclasses only provide GetNumericValue) - PrecursorIntensityColorMapper, ScoreColorMapper (concrete numeric strategies) 28 new tests cover scale normalization and clamping, mapper resolution, brush selection, null guards, and legend title. No regression in existing 40 tests.
Factory resolves a ColorResultsBy to its concrete mapper: - None -> Categorical (gray) - CoverageType -> Categorical using MetaDrawSettings.BioPolymerCoverageColors - FileOrigin -> Categorical using injected identifier brush resolver - PrecursorIntensity -> PrecursorIntensityColorMapper - Score -> ScoreColorMapper 10 new tests cover all branches, null identifier resolver fallback, and unknown enum rejection. Total: 50 color-mapping tests passing.
…tion Wires up the new color-mapping architecture: - Add CreateColorMapper() to resolve mapper from current ColorBy - Add CreateNumericScale(mapper, filteredResults) to derive min/max/range - Add DrawNumericLegend(...) helper to render gradient bar - Drawing loop now calls mapper.GetBrush(result, scale) instead of inline ternaries - Remove ViridisColors, InitViridisPalette, GetIntensityBrush, GetColorBrush (now owned by ViridisColorGradient and the mapper hierarchy) Update existing tests to reflect new abstraction and add 4 new reflection-based tests for CreateColorMapper and CreateNumericScale (non-numeric returns null, numeric derives min/max, all-null precursor intensity falls back to score). 75 color-mapping tests passing; 451 MetaDraw tests passing overall.
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.
Human Explanation.
Add two new color mapping types to the protein coverage overlay.
By Intensity

By Intensity, log scaled

By Score

Motivation
The BioPolymer Coverage view previously colored peptide rectangles only by coverage type (unique/shared/tandem) or file origin. This adds two new coloration modes to visualize intensity and score distributions directly on the coverage map.
Summary
Adds two new
ColorResultsBymodes — PrecursorIntensity and Score — that color each peptide rectangle using a 20-bin viridis scale normalized to the min/max of the current protein group's filtered results.Changes
BioPolymerCoverageMapViewModel.cs:PrecursorIntensityandScoretoColorResultsByenumViridisColorsarray (purple to blue to teal to green to yellow)GetIntensityBrush(normalizedValue)helper for bin mappingGetColorBrush(res)with intensity-aware ternary for the new modesCreateLegendItemsreturns empty for intensity modes (gradient bar replaces text legend)headerBlockHeightaccounts for gradient bar height to prevent overlapTest files:
SetScore(double)toDummySpectralmatchfor test flexibilityViridisColorsinitialization,GetIntensityBrushmapping (bounds, mid, clamping), ColorBy setter,CreateLegendItemsearly return, and integration plotting with various intensity scenarios (nulls, equal values, varying scores)Testing
DummySpectralmatchpattern with reflection for PrecursorIntensity backing field accessMigration
No migration steps. New modes appear automatically in the "Color By" dropdown via
Enum.GetValues. No XAML or configuration changes needed.