varPro Phase 3: gg_udependent — dependency graph for uvarpro fits#86
Merged
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Implements gg_udependent() to extract cross-variable dependency graphs from uvarpro fits via get.beta.entropy/sdependent, with full tidy edges/nodes/igraph output, provenance attribute, and S3 companions. 25 tests pass (1 skip: ggraph not installed in dev env). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…igraph usage and degree semantics - print.gg_udependent, print.summary.gg_udependent → R/print_methods.R - summary.gg_udependent → R/summary_methods.R - autoplot.gg_udependent → R/autoplot_methods.R (calls plot() not plot.gg_udependent directly) - Add @note to gg_udependent roxygen block documenting igraph:: call-site pattern - Expand @return $nodes description with directed/undirected degree semantics - Add inline comment near deg_vec computation explaining out-degree vs total-degree choice Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds plot.gg_udependent S3 method rendering variable dependency graphs via ggraph; empty-graph guard fires before ggraph check so it works without ggraph installed. 26 pass, 3 skip (ggraph not installed), 0 fail. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…le snapshots
- igraph moved from Suggests to Imports (required by importFrom in NAMESPACE)
- plot.gg_udependent example wrapped in requireNamespace("ggraph") guard
- @importFrom igraph added to gg_udependent.R; misleading @note removed
- Stale vdiffr snapshots deleted by devtools::test() cleanup
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Rename single-letter `A` -> `adj_mat` (object_name_linter) - Remove trailing blank line (trailing_blank_lines_linter) - Fix undirected igraph mode: 'undirected' -> 'max' (igraph >= 1.6.0 requires symmetric matrix for mode='undirected'; 'max' symmetrises) - Move gg_udependent vdiffr tests from test_gg_udependent.R into test_snapshots.R under the VDIFFR_RUN_TESTS='true' guard, matching the package convention and preventing CI failures on first-run new snapshots Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #86 +/- ##
==========================================
- Coverage 86.62% 86.39% -0.23%
==========================================
Files 36 38 +2
Lines 2826 3021 +195
==========================================
+ Hits 2448 2610 +162
- Misses 378 411 +33
🚀 New features to boost your workflow:
|
pkgdown fails with 'topics missing from index' when exported functions are not listed in _pkgdown.yml reference section. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new varPro Phase 3 feature to ggRandomForests for extracting and visualizing cross-variable dependency structure from varPro::uvarpro fits, including an igraph-backed data object, ggraph plotting, S3 companions, documentation, and tests.
Changes:
- Introduces
gg_udependent()to compute a dependency graph ($edges,$nodes,$graph) plus a provenance attribute from auvarprofit. - Adds
plot.gg_udependent()(ggraph renderer) and S3 companions (print,summary,autoplot) + corresponding documentation/NAMESPACE updates. - Updates dependencies/tests/metadata (Imports/Suggests, NEWS, pkgdown reference, snapshot tests).
Reviewed changes
Copilot reviewed 13 out of 48 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/testthat/test_snapshots.R | Adds vdiffr snapshot cases for gg_udependent (guarded by env var + ggraph). |
| tests/testthat/test_gg_udependent.R | New unit + smoke tests for gg_udependent structure, provenance, S3 methods, and plotting behavior. |
| tests/testthat/_snaps/snapshots/gg-vimp-survival-rfsrc.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-vimp-regression-rfsrc.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-vimp-regression-rf.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-vimp-classification-rfsrc.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-vimp-classification-rf.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-varpro-default.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-varpro-conditional.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-roc-classification-rfsrc.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-roc-classification-rf.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-rfsrc-regression-rf.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-partial-varpro-mortality.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-partial-varpro-continuous.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-partial-varpro-categorical.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-error-survival-rfsrc.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-error-regression-rfsrc.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-error-regression-rf.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-error-classification-rfsrc.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-brier-survival-overall.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-brier-survival-envelope.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| tests/testthat/_snaps/snapshots/gg-brier-survival-crps.svg | Removes an existing vdiffr baseline snapshot (SVG). |
| R/summary_methods.R | Adds summary.gg_udependent() implementation. |
| R/print_methods.R | Adds print.gg_udependent() and print.summary.gg_udependent(). |
| R/plot.gg_udependent.R | New ggraph-based plot method for gg_udependent. |
| R/gg_udependent.R | New extractor computing dependency adjacency, edges/nodes, and igraph object. |
| R/autoplot_methods.R | Adds autoplot.gg_udependent() delegating to plot(). |
| NEWS.md | Documents the new gg_udependent() feature and dependency update. |
| NAMESPACE | Registers S3 methods and imports required functions (igraph, varPro, ggplot2). |
| man/summary.gg.Rd | Adds alias/usage entry for summary.gg_udependent. |
| man/print.gg.Rd | Adds aliases/usages for print.gg_udependent and print.summary.gg_udependent. |
| man/plot.gg_udependent.Rd | New Rd page for plot.gg_udependent. |
| man/gg_udependent.Rd | New Rd page for gg_udependent. |
| man/autoplot.gg.Rd | Adds alias/usage for autoplot.gg_udependent. |
| dev/plans/2026-05-20-varpro-phase3-gg-udependent-design.md | Adds design document for Phase 3 implementation. |
| DESCRIPTION | Bumps version, moves igraph to Imports, adds ggraph to Suggests. |
| _pkgdown.yml | Adds gg_udependent and plot.gg_udependent to reference index. |
Files not reviewed (5)
- man/autoplot.gg.Rd: Language not supported
- man/gg_udependent.Rd: Language not supported
- man/plot.gg_udependent.Rd: Language not supported
- man/print.gg.Rd: Language not supported
- man/summary.gg.Rd: Language not supported
Comments suppressed due to low confidence (1)
R/gg_udependent.R:116
- Edge weights are currently assigned as
imp_mat[i, j]using the(from, to)ordering returned by igraph. Fordirected = FALSE, this can produce weights that are below the threshold (or otherwise inconsistent) when the undirected edge exists due to the reverse direction. For undirected graphs, compute the edge weight from both directions (e.g., max/mean ofI[i,j]andI[j,i]) so the reported/visualised strength matches the edge selection logic.
## ---- Build tidy edge data frame with raw weights -------------------------
edge_df <- igraph::as_data_frame(g, what = "edges")
if (nrow(edge_df) > 0L) {
edge_df$weight <- mapply(
function(i, j) imp_mat[i, j],
edge_df[[1L]], edge_df[[2L]]
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… guard, snapshots
Undirected adjacency/weights (R/gg_udependent.R):
- Symmetrise adj_mat with pmax(adj_mat, t(adj_mat)) for directed=FALSE
so edge existence matches max(I[i,j], I[j,i]) before igraph build;
mode can now be "undirected" (no longer requires "max" workaround)
- Use max(I[i,j], I[j,i]) as edge weight for undirected graphs
- Set igraph::E(g)$weight in the extractor (order-insensitive key for
undirected) so the plot method never needs to recompute them
Plot weight backfill (R/plot.gg_udependent.R):
- Make legacy backfill order-insensitive for undirected graphs via
pmin/pmax key matching (guards objects saved before weight was stored)
summary API (R/summary_methods.R):
- Rewrite summary.gg_udependent() to use .summary_skel() returning
c("summary.gg_udependent","summary.gg"), consistent with all other
summary.gg_*() methods; body carries edges/nodes/threshold lines
print guard (R/print_methods.R):
- Add NULL-safe provenance fallback in print.gg_udependent()
- Replace print.summary.gg_udependent() body with NextMethod() to
delegate to print.summary.gg() which renders the skel format
Snapshots (tests/testthat/_snaps/):
- Restore 30 SVG baselines from origin/main that were absent from the
branch and appeared as deletions in the PR diff
Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Summary
gg_udependent(): tidy extractor wrappingvarPro::get.beta.entropy()+varPro::sdependent()on auvarprofit. Returns\$edges,\$nodes,\$graph(igraph), and a provenance attribute.plot.gg_udependent(): ggraph network renderer with edge width/opacity by dependency strength, node colour by signal status, configurable layout ("fr","kk","stress", etc.).print,summary,autoplotS3 companions (in shared method files per project convention).igraphfromSuggests:toImports:(required byimportFromin NAMESPACE).ggraphtoSuggests:.2.7.3.9004.Test plan
test_gg_udependent.Rtests pass (806 pass, 11 skip — ggraph/vdiffr skips expected)devtools::check(args='--as-cran')returns 0 errors, 0 warnings, 0 notes🤖 Generated with Claude Code