Vitek-Lab / MSstatsBioNet

https://vitek-lab.github.io/MSstatsPPI/
Other
0 stars 0 forks source link

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

Closed tonywu1999 closed 2 weeks ago

tonywu1999 commented 3 weeks ago

User description

Checklist Before Requesting a Review


PR Type

enhancement


Description


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

    github-actions[bot] commented 3 weeks ago

    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.
    github-actions[bot] commented 3 weeks ago

    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]](https://github.com/Vitek-Lab/MSstatsBioNet/pull/19/files#diff-fa2a69c05887ee5c610e5d06f284de1d083ad342e76535fa9b0001e136653572R51-R51) ```diff 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]](https://github.com/Vitek-Lab/MSstatsBioNet/pull/19/files#diff-fa2a69c05887ee5c610e5d06f284de1d083ad342e76535fa9b0001e136653572R85-R89) ```diff 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]](https://github.com/Vitek-Lab/MSstatsBioNet/pull/19/files#diff-fa2a69c05887ee5c610e5d06f284de1d083ad342e76535fa9b0001e136653572R77-R78) ```diff -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 commented 2 weeks ago

    Codecov Report

    All modified and coverable lines are covered by tests :white_check_mark:

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

    Additional details and impacted files ```diff @@ 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 ```

    :umbrella: View full report in Codecov by Sentry.
    :loudspeaker: Have feedback on the report? Share it here.