Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hupo changes #29

Merged
merged 2 commits into from
Jan 21, 2025
Merged

Hupo changes #29

merged 2 commits into from
Jan 21, 2025

Conversation

tonywu1999
Copy link
Contributor

@tonywu1999 tonywu1999 commented Jan 21, 2025

User description

Motivation and Context

Got the following error: INDRA Exception: Unexpected number of matches for the following HGNC IDs in the input data: 1578 or 8729

This had to do with how we were filtering on the input. Without those which statements, the table slicing operation creates NA entries.

Changes

Please provide a detailed bullet point list of your changes.

Testing

Please describe any unit tests you added or modified to verify your changes.

Checklist Before Requesting a Review

  • I have read the MSstats contributing guidelines
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • Ran styler::style_pkg(transformers = styler::tidyverse_style(indent_by = 4))
  • Ran devtools::document()

PR Type

Bug fix, Enhancement


Description

  • Added filtering to remove rows with NA adj.pvalue.

  • Replaced direct indexing with which for better error handling.

  • Improved robustness in filtering and matching operations.

  • Addressed potential issues with unexpected HGNC ID matches.


Changes walkthrough 📝

Relevant files
Bug fix
utils_getSubnetworkFromIndra.R
Improved filtering and matching in INDRA functions             

R/utils_getSubnetworkFromIndra.R

  • Added filtering to exclude rows with NA adj.pvalue.
  • Replaced direct indexing with which for better error handling.
  • Enhanced robustness in filtering and matching logic.
  • +3/-2     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Filtering Logic

    The added filtering logic on line 46 removes rows with NA adj.pvalue. Ensure this change does not unintentionally exclude valid data or introduce edge cases that could affect downstream processing.

    input <- input[!is.na(input$adj.pvalue),]
    Matching Logic

    The replacement of direct indexing with which on lines 70-71 improves error handling but may have performance implications or edge cases. Validate that this change behaves as expected for all input scenarios.

    matched_rows_source <- input[which(input$HgncId == edge$source_id), ]
    matched_rows_target <- input[which(input$HgncId == edge$target_id), ]

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add a check for column existence

    Ensure that the input data frame has the adj.pvalue column before attempting to
    filter rows based on it to avoid runtime errors when the column is missing.

    R/utils_getSubnetworkFromIndra.R [46]

    -input <- input[!is.na(input$adj.pvalue),]
    +if ("adj.pvalue" %in% colnames(input)) {
    +    input <- input[!is.na(input$adj.pvalue),]
    +}
    Suggestion importance[1-10]: 9

    Why: The suggestion ensures that the code does not throw an error if the adj.pvalue column is missing in the input data frame. This is a critical improvement for robustness and prevents runtime errors.

    9
    Check for column existence before filtering

    Verify that the HgncId column exists in the input data frame before using it in the
    which function to prevent potential errors when the column is missing.

    R/utils_getSubnetworkFromIndra.R [70-71]

    -matched_rows_source <- input[which(input$HgncId == edge$source_id), ]
    -matched_rows_target <- input[which(input$HgncId == edge$target_id), ]
    +if ("HgncId" %in% colnames(input)) {
    +    matched_rows_source <- input[which(input$HgncId == edge$source_id), ]
    +    matched_rows_target <- input[which(input$HgncId == edge$target_id), ]
    +} else {
    +    stop("INDRA Exception: Missing HgncId column in the input data.")
    +}
    Suggestion importance[1-10]: 9

    Why: This suggestion adds a necessary check to ensure the HgncId column exists in the input data frame before using it in the which function. This prevents potential runtime errors and improves the reliability of the function.

    9

    @codecov-commenter
    Copy link

    Codecov Report

    All modified and coverable lines are covered by tests ✅

    Project coverage is 86.73%. Comparing base (3a08390) to head (402d447).

    Additional details and impacted files
    @@            Coverage Diff             @@
    ##            devel      #29      +/-   ##
    ==========================================
    + Coverage   86.69%   86.73%   +0.03%     
    ==========================================
      Files           7        7              
      Lines         406      407       +1     
    ==========================================
    + Hits          352      353       +1     
      Misses         54       54              

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

    @tonywu1999 tonywu1999 merged commit dd20f47 into devel Jan 21, 2025
    4 checks passed
    @tonywu1999 tonywu1999 deleted the hupo-changes branch January 21, 2025 23:11
    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.

    2 participants