Skip to content

Added network provenance and save_network() / load_network() - #132

Merged
tonywu1999 merged 1 commit into
develfrom
MSstatsBioNet/work/20261009_phase5c-provenance
Oct 9, 2026
Merged

tonywu1999 merged 1 commit into
develfrom
MSstatsBioNet/work/20261009_phase5c-provenance

Conversation

@tonywu1999

@tonywu1999 tonywu1999 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • get_network() now also returns provenance, a one-row data.frame: backend_database, query_type, retrieved_at (UTC, taken when the CoGEx response arrives), backend_version (NA for INDRA, which has no data versions), backend_url, organism, parameters (the query arguments as JSON), and package_version. It joins to the edges on backend_database + query_type. INDRA's data changes over time, so this is the only record of which data a network came from. merge_networks() (Added merge_networks() and a shared backend contract test helper #130) already row-binds it.
  • Provenance is a list element, not an edge column: a timestamp describes a retrieval rather than a statement, and when merge_networks() dedups one statement from two retrievals it would otherwise have to drop one of the times.
  • save_network(network, file) validates the network and saves it to .rds, warning when there is no provenance (lost when the list is rebuilt with list(nodes = , edges = )). load_network(file) reads it back and runs validate_network(), naming the file if it fails the current contract.
  • getSubnetworkFromIndra() output is unchanged (no provenance); filter_by_curation() keeps it.

Phase 5c of the API refactor. No new dependencies. Independent of #131: this branch is off devel, and its diff applies cleanly on the #131 branch (1119 tests pass combined), so the two can merge in either order.

Test plan

  • devtools::test(): 1099 pass, 0 fail
  • devtools::check(): 0 errors, 0 warnings, 1 pre-existing NOTE (MSstats in Depends not imported)
  • New test-network-io.R (13 tests): provenance values and join to edges, clock read after the request, custom cogex_url, UTC time, survival through merge_networks() and filter_by_curation(), unchanged getSubnetworkFromIndra() output, save/load round trip, missing-provenance warning, input errors
  • Golden test compares nodes and edges; the INDRA test mock fixes the retrieval time, so the expect_identical test of two get_network() calls no longer depends on both falling in the same second

Co-Authored-By: Claude noreply@anthropic.com

Motivation and solution

Network results need to retain information about how they were retrieved. This change adds provenance to get_network() results and adds save_network() and load_network() to persist and validate networks.

Changes

  • Added provenance as a data frame in get_network() results. It records retrieval details and links to edges by backend_database and query_type.
  • Documented how provenance behaves when networks are merged, filtered, saved, or rebuilt from only nodes and edges.
  • Added and exported save_network(). It validates the network, saves it as an RDS file, warns when provenance is absent, and invisibly returns the file path.
  • Added and exported load_network(). It reads an RDS file and validates the network against the current contract. Validation errors identify the file.
  • Added NEWS entries and help pages for the new functions and provenance behavior.

Tests

  • Added tests for provenance fields, edge association, merging, curation filtering, and network save/load behavior.
  • Added tests for invalid paths, missing files, validation failures, and warnings when provenance is absent.
  • Updated the INDRA mock to use a fixed retrieval time. Updated the golden test to compare nodes and edges.
  • Test execution results were not supplied.

Coding guidelines

  • No coding guideline violations were identified in the supplied information.
  • Current review findings were not supplied, so review severity counts are unavailable.

* get_network() returns provenance: when, from which backend and URL,
  for which organism, and with which arguments the network was retrieved
* save_network() saves a network to .rds, warning without provenance
* load_network() reads it back and checks it with validate_network()
* Tests fix the retrieval time; getSubnetworkFromIndra() is unchanged

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d93210f3-b1f9-4880-9e1e-dd7f22ed06a1

📥 Commits

Reviewing files that changed from the base of the PR and between 619c4fc and e260837.


📒 Files selected for processing (10)
  • NAMESPACE
  • NEWS.md
  • R/AllGenerics.R
  • R/backend-indra.R
  • R/network-io.R
  • man/get_network.Rd
  • man/load_network.Rd
  • man/save_network.Rd
  • tests/testthat/test-backend-indra.R
  • tests/testthat/test-network-io.R

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



📝 Walkthrough

Walkthrough

INDRA network queries now attach provenance describing the query and retrieval. The package also exports functions to save networks to RDS files and load them after validation.

Changes

Network Provenance and Persistence

Layer / File(s) Summary
Capture and preserve query provenance
R/network-io.R, R/backend-indra.R, R/AllGenerics.R, man/get_network.Rd, tests/testthat/test-backend-indra.R, tests/testthat/test-network-io.R
INDRA query results now include provenance fields for the backend, query, retrieval time, organism, parameters, and package version. Tests cover provenance values and edge association, as well as preservation through merging and curation filtering.
Save and load networks
R/network-io.R, NAMESPACE, man/save_network.Rd, man/load_network.Rd, NEWS.md, tests/testthat/test-network-io.R
save_network() validates and saves networks to .rds files, warning when provenance is absent. load_network() reads an RDS file and validates the network. Both functions are exported and documented. Tests cover round trips and validation errors.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature


Merge Risk: ⚪ Minimal · up to e2608

This change adds query provenance to network results and lets users save and load validated networks. No actionable merge-blocking risk was identified.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check Passed The title clearly summarizes the two primary changes: network provenance and the new save_network() and load_network() functions.
Description check Passed The description provides detailed context, changes, testing results, and reported check outcomes. It does not use the template headings or include the checklist, but the required information is mostly…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.


✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

I’m a rabbit with a network to save,
Provenance hops along the trail.
RDS keeps the nodes and edges near,
A careful load checks what is here.
I merge my paths, then pause to see,
My query history travels with me.

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.21%. Comparing base (619c4fc) to head (e260837).

Additional details and impacted files
@@            Coverage Diff             @@
##            devel     #132      +/-   ##
==========================================
+ Coverage   86.97%   87.21%   +0.23%     
==========================================
  Files          24       25       +1     
  Lines        2757     2808      +51     
==========================================
+ Hits         2398     2449      +51     
  Misses        359      359              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tonywu1999
tonywu1999 merged commit 4daf101 into devel Oct 9, 2026
4 checks passed
@tonywu1999
tonywu1999 deleted the MSstatsBioNet/work/20261009_phase5c-provenance branch October 9, 2026 19:23
@tonywu1999 tonywu1999 mentioned this pull request Oct 14, 2026
4 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants