Skip to content

add curation filtering on Shiny for network interpretation#121

Merged
tonywu1999 merged 5 commits intodevelfrom
feature-curation
Feb 24, 2026
Merged

add curation filtering on Shiny for network interpretation#121
tonywu1999 merged 5 commits intodevelfrom
feature-curation

Conversation

@tonywu1999
Copy link
Copy Markdown
Contributor

@tonywu1999 tonywu1999 commented Nov 6, 2025

Motivation and context

  • Motivation: Give users an option in the Shiny network module to exclude INDRA statements that have been curated as incorrect, and remove an explicit external API key dependency from the Shiny code path while keeping behavior stable by default.
  • High-level solution: Add a UI checkbox to toggle curation-based filtering, thread a new boolean parameter filterByCuration through input parsing, subnetwork extraction, and code-generation so INDRA subnetwork calls include filter_by_curation; default the flag to FALSE when unspecified. Update tests and mocks to match the extended signatures.

Detailed changes

  • UI
    • Added createCurationFilterCheckbox(ns): renders a labeled checkbox "Filter out statements curated as incorrect" with a supporting tooltip.
    • Integrated the new checkbox into the Data Upload / filter area of the visualize network UI.
    • Expanded tooltip for "Force Include Proteins" to mention hidden searches by additional biological agents (e.g., drugs, GO terms).
  • Server / input handling
    • getInputParameters now reads filterByCuration and normalizes NULL to FALSE so downstream callers always receive a boolean.
    • Added filterByCuration parameter to extractSubnetwork(…); it is forwarded to getSubnetworkFromIndra as filter_by_curation.
    • visualizeNetworkServer updated to pass filterByCuration into extractSubnetwork.
    • generate_network_code / code-generation path now includes filter_by_curation = filterByCuration when constructing INDRA subnetwork calls.
    • API key: Shiny-side subnetwork call path no longer supplies an explicit api_key parameter (api_key left as default / removed from Shiny invocation).
  • Exports / signatures
    • New exported/public function: createCurationFilterCheckbox(ns).
    • extractSubnetwork(...) signature extended to accept filterByCuration as the final parameter and propagate it through the call chain.

Unit tests added or modified

  • tests/testthat/test_network_visualization.R updated:
    • Mock for getSubnetworkFromIndra (used by tests) extended to accept filter_by_curation so the stub matches the new call signature.
    • Calls to extractSubnetwork in tests updated to include filterByCuration (passed as FALSE where appropriate).
    • Test expectations for returned subnetwork (node/edge counts and shapes) remain unchanged; tests verify behavior with the new parameter present.

Coding guidelines / potential issues

  • Public API & NAMESPACE: A new exported UI helper (createCurationFilterCheckbox) was added — ensure it is documented and exported in NAMESPACE so package checks recognize it as intended public API.
  • Backwards compatibility: extractSubnetwork signature changed (added parameter). Call sites in package code and external users should receive boolean by default (NULL -> FALSE), but consumers calling extractSubnetwork directly may need to adapt if they relied on the previous signature.
  • No other obvious style or guideline violations identified in the changed files reviewed.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 6, 2025

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between efae7f5 and 08b494c.

📒 Files selected for processing (1)
  • tests/testthat/test_network_visualization.R

📝 Walkthrough

Walkthrough

Adds a boolean filterByCuration option (UI checkbox) to the visualize-network module; the value is collected in input parameters, propagated through extractSubnetwork/visualizeNetworkServer, passed as filter_by_curation to getSubnetworkFromIndra, and emitted in generated network code.

Changes

Cohort / File(s) Summary
Curation Filter UI
R/module-visualize-network-ui.R
Added exported createCurationFilterCheckbox(ns) rendering a "Filter out statements curated as incorrect" checkbox with tooltip; integrated into the Data Upload UI and expanded a related tooltip.
Server & Codegen Propagation
R/module-visualize-network-server.R
getInputParameters now includes filterByCuration (NULL → defaults to FALSE). extractSubnetwork(...) signature gains filterByCuration and forwards it as filter_by_curation to getSubnetworkFromIndra. visualizeNetworkServer and generate_network_code updated to pass/emit the new parameter.
Tests
tests/testthat/test_network_visualization.R
Updated mocked and real extractSubnetwork call signatures to accept filter_by_curation/filterByCuration and adjusted test invocations accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant UI as UI (Checkbox)
    participant Server as visualizeNetworkServer
    participant Params as getInputParameters
    participant Extract as extractSubnetwork
    participant Indra as getSubnetworkFromIndra
    participant Codegen as generate_network_code

    UI->>Server: user toggles filterByCuration
    Server->>Params: collect input params (includes filterByCuration)
    Params-->>Server: params{filterByCuration}
    Server->>Extract: call extractSubnetwork(..., filterByCuration)
    Note right of Extract: forwards as filter_by_curation
    Extract->>Indra: getSubnetworkFromIndra(..., filter_by_curation=BOOL, api_key="")
    Server->>Codegen: generate_network_code(params) (emits filter_by_curation=params$filterByCuration)
    Codegen-->>Server: generated network construction code
    Server-->>UI: render updated network
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A checkbox in the grass I spy,
"Filter wrong statements" — I give a try.
I hop through server, extract, and Indra's door,
Carrying my boolean to generated code's core.
🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'add curation filtering on Shiny for network interpretation' directly and clearly describes the main change: introducing a curation filter feature to the Shiny application for network visualization.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature-curation

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

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Nov 6, 2025

Failed to generate code suggestions for PR

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @R/module-visualize-network-server.R:
- Around line 616-618: The generated code now adds filter_by_curation but the
server runtime path forces api_key = "" creating a mismatch; update
generate_network_code to include api_key = "" when the server path forces it, or
better remove the forced api_key = "" in the server runtime so both
code-generation (generate_network_code) and server runtime rely on the same
default behavior; locate generate_network_code and the server runtime block that
sets api_key = "" and either add the same forced api_key parameter to
generate_network_code or eliminate the hard-coded api_key = "" in the server
path so both paths are consistent.
🧹 Nitpick comments (1)
R/module-visualize-network-server.R (1)

244-260: Prefer isTRUE() to coerce filterByCuration into a strict scalar boolean.

Current code works, but as.logical() can yield NA if the input ever becomes a non-boolean string; isTRUE() safely normalizes NULL/FALSE/TRUE into FALSE/TRUE.

Proposed refactor
-  filterByCuration <- if(is.null(input$filterByCuration)) {
-    FALSE  # Default to FALSE if somehow NULL 
-  } else {
-    as.logical(input$filterByCuration)
-  }
+  filterByCuration <- isTRUE(input$filterByCuration)
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c4c6f7a and b1ff54d.

📒 Files selected for processing (1)
  • R/module-visualize-network-server.R
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (2)
R/module-visualize-network-server.R (2)

531-535: Propagation of filterByCuration into extractSubnetwork() looks consistent.


286-303: This review comment is based on incorrect assumptions about parameter support. Both filter_by_curation and api_key are documented, supported parameters in getSubnetworkFromIndra() and will not cause runtime errors. Passing api_key = "" is equivalent to the function default, so no change is necessary.

Likely an incorrect or invalid review comment.

Comment thread R/module-visualize-network-server.R
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@R/module-visualize-network-server.R`:
- Around line 286-296: The function extractSubnetwork currently requires
filterByCuration and breaks callers that pass seven args; make filterByCuration
optional by giving it a default value in the function signature (e.g.,
filterByCuration = FALSE) so existing calls (such as in
tests/testthat/test_network_visualization.R) continue to work; ensure the
default is used when calling getSubnetworkFromIndra (function
getSubnetworkFromIndra invocation already passes filter_by_curation =
filterByCuration) so behavior is unchanged for callers that do pass the
argument.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1ff54d and efae7f5.

📒 Files selected for processing (2)
  • R/module-visualize-network-server.R
  • tests/testthat/test_network_visualization.R

Comment thread R/module-visualize-network-server.R
@tonywu1999 tonywu1999 merged commit 75ce6c2 into devel Feb 24, 2026
2 checks passed
@tonywu1999 tonywu1999 deleted the feature-curation branch February 24, 2026 22:21
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.

1 participant