Repository navigation
3/8 Metrics and plots: vectorised C-index, AUC and ROC (identical values); fixes - #128
Merged
Merged
Conversation
The sample-wise C-index counts concordant and discordant pairs with outer() per group. ROC rates come from cumulative sums over sorted scores, used by AUC and ROCplot's merge mode, and .calcArea works on vectors. Values are identical to the loop implementations, including tie handling and rounding. A class absent from a group gives a clear error instead of 'missing value where TRUE/FALSE needed'; a sample never predicted gets NA. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TfsjwkbDbHkX4kJZNe4ER4
- calcExternalPerformance matches predicted classes to actual classes by name instead of relabelling levels by position, errors on unknown predicted classes, and calculates every requested metric (the loop used the whole vector of metric names). - grouping = "fold" averages C-index and AUC within each permutation into a plain named numeric vector with permutations in numerical order. - easyHard drops samples with missing performance and matches assay rows by sample name; its assay and performanceType defaults work (they are no longer generic arguments); MultiAssayExperiment assays and "clinical" are usable and a matrix assay is converted to a DataFrame. - Documentation: the definitions of precision and recall were swapped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TfsjwkbDbHkX4kJZNe4ER4
- Each result's sample-wise metric is matched to the first result's samples by name, and results must predict the same set of sample names. - comparison = "Cross-validation" uses the characteristic like any other. - showLegends = FALSE, a single result and a class with one sample work. - More than two classes get a white-to-dark gradient per class by default, one legend per class; too few user colours give an error. - The matrix method's class and group bars keep their first and last tiles (limits = c(1, n) dropped them) and its clustering works. - Legends are taken from small plots with one tile per colour; rendered output of the list method is byte-identical to before. - Rd: metric values listed "Sample Error" twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TfsjwkbDbHkX4kJZNe4ER4
Average mode split a DataFrame and subset() with class = aClass (an unused argument). The plot theme is added to each plot instead of theme_set(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TfsjwkbDbHkX4kJZNe4ER4
rotate90 = TRUE replaced user yLimits by c(0, 1) and turned a character x characteristic into NA. Documentation of the box plot default, aggregate and the return value corrected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TfsjwkbDbHkX4kJZNe4ER4
…t rankings Fonts were read from sizesList$fontSizes instead of the documented $fonts; row and column values compared to the whole list; ordering by performance lacked the metric; a ranking shorter than top counted NA as a shared feature. Theme added to the plot instead of theme_set(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TfsjwkbDbHkX4kJZNe4ER4
Importance mode: undefined plot and colourVariable, keepFeatures compared names to counts, y mapped to a constant string, facets were subset by one characteristic at a time. Commonality: duplicate overlap column, and with a reference level the characteristics were looked up in the whole table and repeated the wrong number of times. alpha reaches the geoms; rotate90 works for importance. Theme added to each plot instead of theme_set(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TfsjwkbDbHkX4kJZNe4ER4
…age spacing plotFeatureClasses returned an empty list after printing a message for a useFeatures not in the data; it now stops. Its theme is added to each plot. Adds tests for all plotting fixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TfsjwkbDbHkX4kJZNe4ER4
This was referenced Oct 9, 2026
Merged
DarioS
marked this pull request as ready for review
October 28, 2026 00:35
DarioS
reviewed
Oct 28, 2026
DarioS
left a comment
Member
There was a problem hiding this comment.
I need to personally try all of the changes to samplesMetricMap. It looks good at a glance, but it's a lot.
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
Performance metrics and plots: three slow calculations vectorised with bit-identical output, and fixes to options that failed or gave wrong results.
Why and what
Speed, with identical values (checked with
identical()against the previous code, including ties, absent classes and three classes):Each was measured per result: 165 samples, 100 × 5 CV.
Wrong results:
calcExternalPerformancerelabelled predicted classes by position, so a perfect prediction whose factor levels were in another order scored accuracy 0. It now matches classes by name, and it accepts several performance types.samplesMetricMapaligned samples by position across results and labelled them with the first result's names. It now matches samples by name.easyHarddropped rows by position. It now matches samples by name.Failed on any input:
ROCplot(mode = "average").samplesMetricMapwithcomparison = "Cross-validation",showLegends = FALSE, a single result, or more than two classes.selectionPlotimportance mode.rankingPlot: fonts fromsizesListwere ignored, and there was a row/column copy-paste error.performancePlotreplaced the user'syLimitswhenrotate90 = TRUE.Behaviour:
theme_set(), which changed the user's global ggplot2 theme. The theme is applied to the plot itself, giving byte-identical PNGs.grouping = "fold"returns a numeric vector, not abyobject.Do results change?
Metric values do not. Results change only where a bug is fixed (mismatched factor levels, sample order).
Evidence
211 tests pass (
test-metrics.R,test-plots.R).Questions (left unchanged on purpose)
grouping = "fold".🤖 Generated with Claude Code
https://claude.ai/code/session_01TfsjwkbDbHkX4kJZNe4ER4