Skip to content

Commit

Permalink
refactor(collapse-edges): Refactor how edges are collapsed to remove …
Browse files Browse the repository at this point in the history
…clutter
  • Loading branch information
tonywu1999 committed Oct 22, 2024
1 parent a2e77b9 commit 2ad3653
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions R/utils_getSubnetworkFromIndra.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
edge$evidence_list <- paste(
"https://db.indra.bio/statements/from_agents?subject=",
edge$source_id, "@HGNC&object=",
edge$target_id, "@HGNC&type=",
edge$data$stmt_type, "&format=html",
edge$target_id, "&format=html",
sep = ""
)
edge$source_uniprot_id <- input[input$HgncId == edge$source_id, ]$Protein
Expand All @@ -69,18 +68,26 @@
edgeToMetadataMapping <- hashmap()

for (edge in res) {
key <- paste(edge$source_id, edge$target_id, edge$data$stmt_type,
sep = "_"
)
key <- paste(edge$source_id, edge$target_id, sep = "_")
if (key %in% keys(edgeToMetadataMapping)) {
edgeToMetadataMapping[[key]]$data$evidence_count <-
edgeToMetadataMapping[[key]]$data$evidence_count +
edge$data$evidence_count
edgeToMetadataMapping[[key]]$data$stmt_type <- c(
edgeToMetadataMapping[[key]]$data$stmt_type,
edge$data$stmt_type)
} else {
edge <- .addAdditionalMetadataToIndraEdge(edge, input)
edgeToMetadataMapping[[key]] <- edge
}
}

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 = ", ")
}

return(edgeToMetadataMapping)
}
Expand Down

0 comments on commit 2ad3653

Please sign in to comment.