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

refactor(collapse-edges): Refactor how edges are collapsed to remove clutter #19

Merged
merged 3 commits into from
Oct 31, 2024

Conversation

tonywu1999
Copy link
Contributor

@tonywu1999 tonywu1999 commented Oct 22, 2024

User description

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

enhancement


Description

  • Refactored the function .addAdditionalMetadataToIndraEdge to simplify the URL construction by removing the stmt_type parameter.
  • Updated the .collapseDuplicateEdgesIntoEdgeToMetadataMapping function to modify key generation by excluding stmt_type, allowing for more efficient edge collapsing.
  • Enhanced the handling of stmt_type by storing it as a list, ensuring uniqueness, and concatenating the values into a single string for better metadata representation.

Changes walkthrough 📝

Relevant files
Enhancement
utils_getSubnetworkFromIndra.R
Refactor edge metadata handling and key generation             

R/utils_getSubnetworkFromIndra.R

  • Removed stmt_type from the evidence list URL construction.
  • Modified key generation by excluding stmt_type.
  • Updated logic to handle stmt_type as a list and ensure uniqueness.
  • Concatenated stmt_type values into a single string.
  • +12/-5   

    💡 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

    Code Redundancy
    The new implementation in .collapseDuplicateEdgesIntoEdgeToMetadataMapping function seems to handle stmt_type multiple times which could be optimized.

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Correct the URL construction to include '@HGNC' for the target ID

    Ensure that the URL construction in .addAdditionalMetadataToIndraEdge function does
    not lead to malformed URLs due to missing '@HGNC' for the target ID.

    R/utils_getSubnetworkFromIndra.R [51]

     edge$evidence_list <- paste(
         "https://db.indra.bio/statements/from_agents?subject=",
         edge$source_id, "@HGNC&object=",
    -    edge$target_id, "&format=html",
    +    edge$target_id, "@HGNC&format=html",
         sep = ""
     )
    Suggestion importance[1-10]: 9

    Why: This suggestion addresses a potential bug by ensuring that the URL is correctly formed with the '@HGNC' suffix for the target ID, which is crucial for the functionality of the URL construction.

    9
    Performance
    Streamline the conversion of statement types to a unique, comma-separated string

    Consolidate the operations for making statement types unique and converting them to
    a string to reduce redundancy and improve performance.

    R/utils_getSubnetworkFromIndra.R [85-89]

     for (key in keys(edgeToMetadataMapping)) {
         edgeToMetadataMapping[[key]]$data$stmt_type <-
    -        unique(edgeToMetadataMapping[[key]]$data$stmt_type)
    -    edgeToMetadataMapping[[key]]$data$stmt_type <-
    -        paste(edgeToMetadataMapping[[key]]$data$stmt_type, collapse = ", ")
    +        paste(unique(edgeToMetadataMapping[[key]]$data$stmt_type), collapse = ", ")
     }
    Suggestion importance[1-10]: 8

    Why: This suggestion improves performance and reduces redundancy by consolidating operations into a single step, which is a beneficial optimization.

    8
    Enhancement
    Use unique to prevent duplication when merging statement types

    Avoid potential duplication of statement types in the hashmap by directly using
    unique when adding new types.

    R/utils_getSubnetworkFromIndra.R [77-78]

    -edgeToMetadataMapping[[key]]$data$stmt_type <- c(
    +edgeToMetadataMapping[[key]]$data$stmt_type <- unique(c(
         edgeToMetadataMapping[[key]]$data$stmt_type,
    -    edge$data$stmt_type)
    +    edge$data$stmt_type))
    Suggestion importance[1-10]: 7

    Why: The suggestion enhances the code by preventing duplication of statement types, which improves the integrity of the data stored in the hashmap.

    7

    @codecov-commenter
    Copy link

    codecov-commenter commented Oct 31, 2024

    Codecov Report

    All modified and coverable lines are covered by tests ✅

    Project coverage is 88.28%. Comparing base (a2e77b9) to head (2150348).

    Additional details and impacted files
    @@            Coverage Diff             @@
    ##            devel      #19      +/-   ##
    ==========================================
    + Coverage   87.85%   88.28%   +0.43%     
    ==========================================
      Files           3        3              
      Lines         107      111       +4     
    ==========================================
    + Hits           94       98       +4     
      Misses         13       13              

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

    @tonywu1999 tonywu1999 merged commit b4692ab into devel Oct 31, 2024
    3 checks passed
    @tonywu1999 tonywu1999 deleted the collapse branch October 31, 2024 16:03
    pnavada pushed a commit that referenced this pull request Nov 15, 2024
    …clutter (#19)
    
    * refactor(collapse-edges): Refactor how edges are collapsed to remove clutter
    
    * fixed unit tests, adjusted codium secret
    
    * added additional corrections from chatGPT
    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