Skip to content

MetaDraw: Add Score and Intensity coloration modes to BioPolymerCoverage View#2684

Open
nbollis wants to merge 9 commits into
smith-chem-wisc:masterfrom
nbollis:SequenceCoverageColorSchemes
Open

MetaDraw: Add Score and Intensity coloration modes to BioPolymerCoverage View#2684
nbollis wants to merge 9 commits into
smith-chem-wisc:masterfrom
nbollis:SequenceCoverageColorSchemes

Conversation

@nbollis

@nbollis nbollis commented Jul 10, 2026

Copy link
Copy Markdown
Member

Human Explanation.

Add two new color mapping types to the protein coverage overlay.

By Intensity
image

By Intensity, log scaled
image

By Score
image

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 ColorResultsBy modes — 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:

  • Added PrecursorIntensity and Score to ColorResultsBy enum
  • Added 20-color static ViridisColors array (purple to blue to teal to green to yellow)
  • Added GetIntensityBrush(normalizedValue) helper for bin mapping
  • Pre-computes min/max/range per group before the drawing loop
  • Replaces GetColorBrush(res) with intensity-aware ternary for the new modes
  • Draws a gradient bar in the legend showing the metric name and actual min/max values
  • CreateLegendItems returns empty for intensity modes (gradient bar replaces text legend)
  • headerBlockHeight accounts for gradient bar height to prevent overlap

Test files:

  • Added SetScore(double) to DummySpectralmatch for test flexibility
  • 14 new tests covering ViridisColors initialization, GetIntensityBrush mapping (bounds, mid, clamping), ColorBy setter, CreateLegendItems early return, and integration plotting with various intensity scenarios (nulls, equal values, varying scores)

Testing

  • All 16 test methods pass
  • Categories: unit (brush mapping), integration (CoverageDrawing produced), edge case (all equal values, null PrecursorIntensity, clamping)
  • Uses existing DummySpectralmatch pattern with reflection for PrecursorIntensity backing field access

Migration

No migration steps. New modes appear automatically in the "Color By" dropdown via Enum.GetValues. No XAML or configuration changes needed.

nbollis added 2 commits July 10, 2026 14:20
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).
@nbollis nbollis changed the title Add viridis intensity coloration modes to BioPolymerCoverage MetaDraw: Add Score and Intensity coloration modes to BioPolymerCoverage View Jul 10, 2026
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.80000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.31%. Comparing base (3c8e0b8) to head (fd4a177).

Files with missing lines Patch % Lines
...oPolymerCoverage/BioPolymerCoverageMapViewModel.cs 98.24% 0 Missing and 1 partial ⚠️
...apping/CategoricalBioPolymerCoverageColorMapper.cs 88.88% 0 Missing and 1 partial ⚠️
...rage/ColorMapping/PrecursorIntensityColorMapper.cs 50.00% 0 Missing and 1 partial ⚠️
...ioPolymerCoverage/ColorMapping/ScoreColorMapper.cs 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
unittests 93.31% <96.80%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...rage/ColorMapping/BioPolymerCoverageColorMapper.cs 100.00% <100.00%> (ø)
...lorMapping/BioPolymerCoverageColorMapperFactory.cs 100.00% <100.00%> (ø)
...erage/ColorMapping/BioPolymerCoverageColorScale.cs 100.00% <100.00%> (ø)
...lymerCoverage/ColorMapping/ColorGradientFactory.cs 100.00% <100.00%> (ø)
...lorMapping/NumericBioPolymerCoverageColorMapper.cs 100.00% <100.00%> (ø)
...lymerCoverage/ColorMapping/ViridisColorGradient.cs 100.00% <100.00%> (ø)
...oPolymerCoverage/BioPolymerCoverageMapViewModel.cs 95.41% <98.24%> (+0.35%) ⬆️
...apping/CategoricalBioPolymerCoverageColorMapper.cs 88.88% <88.88%> (ø)
...rage/ColorMapping/PrecursorIntensityColorMapper.cs 50.00% <50.00%> (ø)
...ioPolymerCoverage/ColorMapping/ScoreColorMapper.cs 50.00% <50.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

nbollis added 2 commits July 13, 2026 12:25
… 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
zhuoxinshi previously approved these changes Jul 14, 2026
RayMSMS
RayMSMS previously approved these changes Jul 14, 2026
nbollis added 4 commits July 14, 2026 13:32
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.
@nbollis nbollis dismissed stale reviews from RayMSMS and zhuoxinshi via fd4a177 July 14, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants