From f4e84c15a7484ca44715873cde138f4160bc5e88 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Fri, 24 Oct 2025 16:17:22 -0400 Subject: [PATCH 01/17] initial trial of only filtering down to known phosphosites --- R/getSubnetworkFromIndra.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/getSubnetworkFromIndra.R b/R/getSubnetworkFromIndra.R index ab3e232..f27b672 100644 --- a/R/getSubnetworkFromIndra.R +++ b/R/getSubnetworkFromIndra.R @@ -66,6 +66,9 @@ getSubnetworkFromIndra <- function(input, edges <- .constructEdgesDataFrame(res, input, protein_level_data) edges <- .filterEdgesDataFrame(edges, paper_count_cutoff, correlation_cutoff) nodes <- .constructNodesDataFrame(input, edges) + ptm_overlap <- calculatePTMOverlapAggregated(edges, nodes) + edges <- edges[ptm_overlap[paste(edges$source, edges$target, edges$interaction, sep = "-")] != "", ] + nodes <- nodes[nodes$id %in% c(edges$source, edges$target), ] warning( "NOTICE: This function includes third-party software components that are licensed under the BSD 2-Clause License. Please ensure to From b5936625ab8eb1532f3e772310ed09728ceb87f2 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Fri, 7 Nov 2025 11:07:04 -0500 Subject: [PATCH 02/17] adjust curation filtering --- R/getSubnetworkFromIndra.R | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/R/getSubnetworkFromIndra.R b/R/getSubnetworkFromIndra.R index f27b672..cf5eb3d 100644 --- a/R/getSubnetworkFromIndra.R +++ b/R/getSubnetworkFromIndra.R @@ -69,6 +69,16 @@ getSubnetworkFromIndra <- function(input, ptm_overlap <- calculatePTMOverlapAggregated(edges, nodes) edges <- edges[ptm_overlap[paste(edges$source, edges$target, edges$interaction, sep = "-")] != "", ] nodes <- nodes[nodes$id %in% c(edges$source, edges$target), ] + if (filter_by_curation) { + for (i in seq(1, nrow(edges))) { + stmt_hash <- edges$statement_hash[i] + incorrect_count <- .get_incorrect_curation_count(stmt_hash, api_key) + edges$evidence_count[i] <- edges$evidence_count[i] - incorrect_count + Sys.sleep(0.1) + } + edges <- edges[edges$evidence_count >= evidence_count_cutoff, ] + nodes <- nodes[nodes$id %in% c(edges$source, edges$target), ] + } warning( "NOTICE: This function includes third-party software components that are licensed under the BSD 2-Clause License. Please ensure to From a641336343077b063b34ba7abc37ee329bdb4333 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Fri, 7 Nov 2025 11:07:26 -0500 Subject: [PATCH 03/17] make curation filtering more efficient --- R/utils_getSubnetworkFromIndra.R | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/R/utils_getSubnetworkFromIndra.R b/R/utils_getSubnetworkFromIndra.R index 3f3a674..87d7430 100644 --- a/R/utils_getSubnetworkFromIndra.R +++ b/R/utils_getSubnetworkFromIndra.R @@ -123,16 +123,16 @@ res ) } - if (filter_by_curation) { - for (i in seq_along(res)) { - stmt_json <- fromJSON(res[[i]]$data$stmt_json) - stmt_hash <- stmt_json$matches_hash - incorrect_count <- .get_incorrect_curation_count(stmt_hash, api_key) - res[[i]]$data$evidence_count <- res[[i]]$data$evidence_count - incorrect_count - # Todo: Also subtract source_counts accordingly if requested - Sys.sleep(0.1) - } - } + # if (filter_by_curation) { + # for (i in seq_along(res)) { + # stmt_json <- fromJSON(res[[i]]$data$stmt_json) + # stmt_hash <- stmt_json$matches_hash + # incorrect_count <- .get_incorrect_curation_count(stmt_hash, api_key) + # res[[i]]$data$evidence_count <- res[[i]]$data$evidence_count - incorrect_count + # # Todo: Also subtract source_counts accordingly if requested + # Sys.sleep(0.1) + # } + # } res = Filter( function(statement) statement$data$evidence_count >= evidence_count_cutoff, res From 71feccc66e0faf4a3cf7d6d1b4b453d3199b99f1 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Fri, 7 Nov 2025 12:01:28 -0500 Subject: [PATCH 04/17] fix statement hash problem --- R/getSubnetworkFromIndra.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/getSubnetworkFromIndra.R b/R/getSubnetworkFromIndra.R index cf5eb3d..07af1fd 100644 --- a/R/getSubnetworkFromIndra.R +++ b/R/getSubnetworkFromIndra.R @@ -71,7 +71,7 @@ getSubnetworkFromIndra <- function(input, nodes <- nodes[nodes$id %in% c(edges$source, edges$target), ] if (filter_by_curation) { for (i in seq(1, nrow(edges))) { - stmt_hash <- edges$statement_hash[i] + stmt_hash <- edges$stmt_hash[i] incorrect_count <- .get_incorrect_curation_count(stmt_hash, api_key) edges$evidence_count[i] <- edges$evidence_count[i] - incorrect_count Sys.sleep(0.1) From 5269fdc2299caa5e6a274591de0d429c503cbcbe Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Fri, 7 Nov 2025 12:12:05 -0500 Subject: [PATCH 05/17] fix curation bug --- R/getSubnetworkFromIndra.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/getSubnetworkFromIndra.R b/R/getSubnetworkFromIndra.R index 07af1fd..3d2b738 100644 --- a/R/getSubnetworkFromIndra.R +++ b/R/getSubnetworkFromIndra.R @@ -76,7 +76,7 @@ getSubnetworkFromIndra <- function(input, edges$evidence_count[i] <- edges$evidence_count[i] - incorrect_count Sys.sleep(0.1) } - edges <- edges[edges$evidence_count >= evidence_count_cutoff, ] + edges <- edges[edges$evidenceCount >= evidence_count_cutoff, ] nodes <- nodes[nodes$id %in% c(edges$source, edges$target), ] } warning( From 357e48becb828119b2e05d3c95d13dd1eb6cc766 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Fri, 7 Nov 2025 12:18:42 -0500 Subject: [PATCH 06/17] get correct column for evidenceCount --- R/getSubnetworkFromIndra.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/getSubnetworkFromIndra.R b/R/getSubnetworkFromIndra.R index 3d2b738..f56c59e 100644 --- a/R/getSubnetworkFromIndra.R +++ b/R/getSubnetworkFromIndra.R @@ -70,12 +70,12 @@ getSubnetworkFromIndra <- function(input, edges <- edges[ptm_overlap[paste(edges$source, edges$target, edges$interaction, sep = "-")] != "", ] nodes <- nodes[nodes$id %in% c(edges$source, edges$target), ] if (filter_by_curation) { - for (i in seq(1, nrow(edges))) { - stmt_hash <- edges$stmt_hash[i] - incorrect_count <- .get_incorrect_curation_count(stmt_hash, api_key) - edges$evidence_count[i] <- edges$evidence_count[i] - incorrect_count + incorrect_counts <- numeric(nrow(edges)) + for (i in seq_len(nrow(edges))) { + incorrect_counts[i] <- .get_incorrect_curation_count(edges$stmt_hash[i], api_key) Sys.sleep(0.1) } + edges$evidenceCount <- edges$evidenceCount - incorrect_counts edges <- edges[edges$evidenceCount >= evidence_count_cutoff, ] nodes <- nodes[nodes$id %in% c(edges$source, edges$target), ] } From f0743870a583798238af4b2097808ae827416cf6 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Fri, 7 Nov 2025 12:29:51 -0500 Subject: [PATCH 07/17] get rid of na site temporarily --- R/getSubnetworkFromIndra.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/getSubnetworkFromIndra.R b/R/getSubnetworkFromIndra.R index f56c59e..7ae374a 100644 --- a/R/getSubnetworkFromIndra.R +++ b/R/getSubnetworkFromIndra.R @@ -68,6 +68,7 @@ getSubnetworkFromIndra <- function(input, nodes <- .constructNodesDataFrame(input, edges) ptm_overlap <- calculatePTMOverlapAggregated(edges, nodes) edges <- edges[ptm_overlap[paste(edges$source, edges$target, edges$interaction, sep = "-")] != "", ] + edges <- edges[!is.na(edges$site),] nodes <- nodes[nodes$id %in% c(edges$source, edges$target), ] if (filter_by_curation) { incorrect_counts <- numeric(nrow(edges)) From d13da36b4308f94e5b57655444cd1c1e28b5ec85 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Fri, 7 Nov 2025 14:58:05 -0500 Subject: [PATCH 08/17] fix bug with ptm adjustment --- R/getSubnetworkFromIndra.R | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/R/getSubnetworkFromIndra.R b/R/getSubnetworkFromIndra.R index 7ae374a..27497dd 100644 --- a/R/getSubnetworkFromIndra.R +++ b/R/getSubnetworkFromIndra.R @@ -66,10 +66,12 @@ getSubnetworkFromIndra <- function(input, edges <- .constructEdgesDataFrame(res, input, protein_level_data) edges <- .filterEdgesDataFrame(edges, paper_count_cutoff, correlation_cutoff) nodes <- .constructNodesDataFrame(input, edges) - ptm_overlap <- calculatePTMOverlapAggregated(edges, nodes) - edges <- edges[ptm_overlap[paste(edges$source, edges$target, edges$interaction, sep = "-")] != "", ] - edges <- edges[!is.na(edges$site),] - nodes <- nodes[nodes$id %in% c(edges$source, edges$target), ] + if (nrow(edges[!is.na(edges$site), ]) > 0) { + ptm_overlap <- calculatePTMOverlapAggregated(edges, nodes) + edges <- edges[ptm_overlap[paste(edges$source, edges$target, edges$interaction, sep = "-")] != "", ] + edges <- edges[!is.na(edges$site),] + nodes <- nodes[nodes$id %in% c(edges$source, edges$target), ] + } if (filter_by_curation) { incorrect_counts <- numeric(nrow(edges)) for (i in seq_len(nrow(edges))) { From 8cf6fbf0e5ef2011633c5b71e14905d645b68aa8 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Fri, 7 Nov 2025 15:23:48 -0500 Subject: [PATCH 09/17] fix ptm execution problem --- R/getSubnetworkFromIndra.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/getSubnetworkFromIndra.R b/R/getSubnetworkFromIndra.R index 27497dd..1db77cd 100644 --- a/R/getSubnetworkFromIndra.R +++ b/R/getSubnetworkFromIndra.R @@ -66,7 +66,7 @@ getSubnetworkFromIndra <- function(input, edges <- .constructEdgesDataFrame(res, input, protein_level_data) edges <- .filterEdgesDataFrame(edges, paper_count_cutoff, correlation_cutoff) nodes <- .constructNodesDataFrame(input, edges) - if (nrow(edges[!is.na(edges$site), ]) > 0) { + if (nrow(nodes[!is.na(nodes$Site), ]) > 0) { ptm_overlap <- calculatePTMOverlapAggregated(edges, nodes) edges <- edges[ptm_overlap[paste(edges$source, edges$target, edges$interaction, sep = "-")] != "", ] edges <- edges[!is.na(edges$site),] From 7ece0b8fcf827ee910b49b38a43ae9e7c20c1906 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Tue, 24 Feb 2026 15:38:12 -0500 Subject: [PATCH 10/17] adjust filtering by curation as a separate subfunction --- R/getSubnetworkFromIndra.R | 11 +---------- R/utils_getSubnetworkFromIndra.R | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/R/getSubnetworkFromIndra.R b/R/getSubnetworkFromIndra.R index 1db77cd..9bf27e7 100644 --- a/R/getSubnetworkFromIndra.R +++ b/R/getSubnetworkFromIndra.R @@ -72,16 +72,7 @@ getSubnetworkFromIndra <- function(input, edges <- edges[!is.na(edges$site),] nodes <- nodes[nodes$id %in% c(edges$source, edges$target), ] } - if (filter_by_curation) { - incorrect_counts <- numeric(nrow(edges)) - for (i in seq_len(nrow(edges))) { - incorrect_counts[i] <- .get_incorrect_curation_count(edges$stmt_hash[i], api_key) - Sys.sleep(0.1) - } - edges$evidenceCount <- edges$evidenceCount - incorrect_counts - edges <- edges[edges$evidenceCount >= evidence_count_cutoff, ] - nodes <- nodes[nodes$id %in% c(edges$source, edges$target), ] - } + subnetwork = .filterByCuration(nodes, edges, filter_by_curation) warning( "NOTICE: This function includes third-party software components that are licensed under the BSD 2-Clause License. Please ensure to diff --git a/R/utils_getSubnetworkFromIndra.R b/R/utils_getSubnetworkFromIndra.R index 87d7430..57d885f 100644 --- a/R/utils_getSubnetworkFromIndra.R +++ b/R/utils_getSubnetworkFromIndra.R @@ -99,15 +99,12 @@ #' @param interaction_types interaction types to filter by #' @param evidence_count_cutoff number of evidence to filter on for each paper #' @param sources_filter list of sources to filter by. Default is NULL, i.e. no filter -#' @param filter_by_curation logical, whether to filter out statements that -#' have been curated as incorrect in INDRA. Default is FALSE. -#' @param api_key string of INDRA API key for accessing curated statements. #' @return filtered list of INDRA statements #' @importFrom jsonlite fromJSON #' @keywords internal #' @noRd .filterIndraResponse <- function(res, interaction_types, evidence_count_cutoff, - sources_filter = NULL, filter_by_curation = FALSE, api_key = "") { + sources_filter = NULL) { if (!is.null(interaction_types)) { res = Filter( function(statement) statement$data$stmt_type %in% interaction_types, @@ -123,16 +120,6 @@ res ) } - # if (filter_by_curation) { - # for (i in seq_along(res)) { - # stmt_json <- fromJSON(res[[i]]$data$stmt_json) - # stmt_hash <- stmt_json$matches_hash - # incorrect_count <- .get_incorrect_curation_count(stmt_hash, api_key) - # res[[i]]$data$evidence_count <- res[[i]]$data$evidence_count - incorrect_count - # # Todo: Also subtract source_counts accordingly if requested - # Sys.sleep(0.1) - # } - # } res = Filter( function(statement) statement$data$evidence_count >= evidence_count_cutoff, res @@ -373,6 +360,20 @@ return(edges) } +.filterByCuration = function(nodes, edges, filter_by_curation) { + if (filter_by_curation) { + incorrect_counts <- numeric(nrow(edges)) + for (i in seq_len(nrow(edges))) { + incorrect_counts[i] <- .get_incorrect_curation_count(edges$stmt_hash[i], api_key) + Sys.sleep(0.1) + } + edges$evidenceCount <- edges$evidenceCount - incorrect_counts + edges <- edges[edges$evidenceCount >= evidence_count_cutoff, ] + nodes <- nodes[nodes$id %in% c(edges$source, edges$target), ] + } + return(list(nodes = nodes, edges = edges)) +} + #' Construct correlation matrix from MSstats #' @param protein_level_data output of dataProcess #' @importFrom tidyr pivot_wider From 76cd92a9c055c9a30491667992a736169b525c38 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Tue, 24 Feb 2026 15:39:09 -0500 Subject: [PATCH 11/17] fix curation code --- R/utils_getSubnetworkFromIndra.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/utils_getSubnetworkFromIndra.R b/R/utils_getSubnetworkFromIndra.R index 57d885f..4b14fd0 100644 --- a/R/utils_getSubnetworkFromIndra.R +++ b/R/utils_getSubnetworkFromIndra.R @@ -68,9 +68,9 @@ #' @importFrom httr GET status_code content #' @importFrom jsonlite fromJSON -.get_incorrect_curation_count <- function(stmt_hash, api_key) { +.get_incorrect_curation_count <- function(stmt_hash) { stmt_hash_char <- as.character(stmt_hash) - url <- paste0("https://db.indra.bio/curation/list/", stmt_hash_char, "?api_key=", api_key) + url <- paste0("https://db.indra.bio/curation/list/", stmt_hash_char) tryCatch({ response <- GET(url) @@ -364,7 +364,7 @@ if (filter_by_curation) { incorrect_counts <- numeric(nrow(edges)) for (i in seq_len(nrow(edges))) { - incorrect_counts[i] <- .get_incorrect_curation_count(edges$stmt_hash[i], api_key) + incorrect_counts[i] <- .get_incorrect_curation_count(edges$stmt_hash[i]) Sys.sleep(0.1) } edges$evidenceCount <- edges$evidenceCount - incorrect_counts From 405802c11dbd4b7b77a8972927a629a604398e55 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Tue, 24 Feb 2026 15:40:47 -0500 Subject: [PATCH 12/17] update docs --- R/getSubnetworkFromIndra.R | 4 +--- man/exportNetworkToHTML.Rd | 1 + man/generateCytoscapeConfig.Rd | 3 ++- man/getSubnetworkFromIndra.Rd | 5 +---- man/previewNetworkInBrowser.Rd | 8 +++++++- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/R/getSubnetworkFromIndra.R b/R/getSubnetworkFromIndra.R index 9bf27e7..faf4c52 100644 --- a/R/getSubnetworkFromIndra.R +++ b/R/getSubnetworkFromIndra.R @@ -32,7 +32,6 @@ #' as "namespace:identifier", e.g. "HGNC:1234" or "CHEBI:4911". #' @param filter_by_curation logical, whether to filter out statements that #' have been curated as incorrect in INDRA. Default is FALSE. -#' @param api_key string of INDRA API key for accessing curated statements. #' #' @return list of 2 data.frames, nodes and edges #' @@ -57,8 +56,7 @@ getSubnetworkFromIndra <- function(input, sources_filter = NULL, logfc_cutoff = NULL, force_include_other = NULL, - filter_by_curation = FALSE, - api_key = "") { + filter_by_curation = FALSE) { input <- .filterGetSubnetworkFromIndraInput(input, pvalueCutoff, logfc_cutoff, force_include_other) .validateGetSubnetworkFromIndraInput(input, protein_level_data, sources_filter, force_include_other) res <- .callIndraCogexApi(input$HgncId, force_include_other) diff --git a/man/exportNetworkToHTML.Rd b/man/exportNetworkToHTML.Rd index 2e9910a..d5f9a7d 100644 --- a/man/exportNetworkToHTML.Rd +++ b/man/exportNetworkToHTML.Rd @@ -9,6 +9,7 @@ exportNetworkToHTML( edges, filename = "network_visualization.html", displayLabelType = "id", + nodeFontSize = 12, ... ) } diff --git a/man/generateCytoscapeConfig.Rd b/man/generateCytoscapeConfig.Rd index 07c70b8..fc6c562 100644 --- a/man/generateCytoscapeConfig.Rd +++ b/man/generateCytoscapeConfig.Rd @@ -10,7 +10,8 @@ generateCytoscapeConfig( display_label_type = "id", container_id = "network-cy", event_handlers = NULL, - layout_options = NULL + layout_options = NULL, + node_font_size = 12 ) } \arguments{ diff --git a/man/getSubnetworkFromIndra.Rd b/man/getSubnetworkFromIndra.Rd index 94d27f9..8722e39 100644 --- a/man/getSubnetworkFromIndra.Rd +++ b/man/getSubnetworkFromIndra.Rd @@ -15,8 +15,7 @@ getSubnetworkFromIndra( sources_filter = NULL, logfc_cutoff = NULL, force_include_other = NULL, - filter_by_curation = FALSE, - api_key = "" + filter_by_curation = FALSE ) } \arguments{ @@ -59,8 +58,6 @@ as "namespace:identifier", e.g. "HGNC:1234" or "CHEBI:4911".} \item{filter_by_curation}{logical, whether to filter out statements that have been curated as incorrect in INDRA. Default is FALSE.} - -\item{api_key}{string of INDRA API key for accessing curated statements.} } \value{ list of 2 data.frames, nodes and edges diff --git a/man/previewNetworkInBrowser.Rd b/man/previewNetworkInBrowser.Rd index 6dde024..d0ac40e 100644 --- a/man/previewNetworkInBrowser.Rd +++ b/man/previewNetworkInBrowser.Rd @@ -4,7 +4,13 @@ \alias{previewNetworkInBrowser} \title{Preview network in browser} \usage{ -previewNetworkInBrowser(nodes, edges, displayLabelType = "id", ...) +previewNetworkInBrowser( + nodes, + edges, + displayLabelType = "id", + nodeFontSize = 12, + ... +) } \arguments{ \item{nodes}{Data frame with node information} From fcebec1206267ad1590e83f234260aad08294261 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Tue, 24 Feb 2026 15:45:17 -0500 Subject: [PATCH 13/17] enable option to filter by ptm site --- R/getSubnetworkFromIndra.R | 17 ++++++++--------- R/utils_getSubnetworkFromIndra.R | 10 ++++++++++ man/getSubnetworkFromIndra.Rd | 7 ++++++- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/R/getSubnetworkFromIndra.R b/R/getSubnetworkFromIndra.R index faf4c52..027d426 100644 --- a/R/getSubnetworkFromIndra.R +++ b/R/getSubnetworkFromIndra.R @@ -32,6 +32,9 @@ #' as "namespace:identifier", e.g. "HGNC:1234" or "CHEBI:4911". #' @param filter_by_curation logical, whether to filter out statements that #' have been curated as incorrect in INDRA. Default is FALSE. +#' @param filter_by_ptm_site logical, whether to filter edges based on whether the +#' site information from INDRA matches with the PTM site in the input. Default is FALSE. +#' Only applicable for differential PTM abundance results. #' #' @return list of 2 data.frames, nodes and edges #' @@ -56,7 +59,8 @@ getSubnetworkFromIndra <- function(input, sources_filter = NULL, logfc_cutoff = NULL, force_include_other = NULL, - filter_by_curation = FALSE) { + filter_by_curation = FALSE, + filter_by_ptm_site = FALSE) { input <- .filterGetSubnetworkFromIndraInput(input, pvalueCutoff, logfc_cutoff, force_include_other) .validateGetSubnetworkFromIndraInput(input, protein_level_data, sources_filter, force_include_other) res <- .callIndraCogexApi(input$HgncId, force_include_other) @@ -64,13 +68,8 @@ getSubnetworkFromIndra <- function(input, edges <- .constructEdgesDataFrame(res, input, protein_level_data) edges <- .filterEdgesDataFrame(edges, paper_count_cutoff, correlation_cutoff) nodes <- .constructNodesDataFrame(input, edges) - if (nrow(nodes[!is.na(nodes$Site), ]) > 0) { - ptm_overlap <- calculatePTMOverlapAggregated(edges, nodes) - edges <- edges[ptm_overlap[paste(edges$source, edges$target, edges$interaction, sep = "-")] != "", ] - edges <- edges[!is.na(edges$site),] - nodes <- nodes[nodes$id %in% c(edges$source, edges$target), ] - } - subnetwork = .filterByCuration(nodes, edges, filter_by_curation) + subnetwork = .filterByPtmSite(nodes, edges, filter_by_ptm_site) + subnetwork = .filterByCuration(subnetwork$nodes, subnetwork$edges, filter_by_curation) warning( "NOTICE: This function includes third-party software components that are licensed under the BSD 2-Clause License. Please ensure to @@ -78,5 +77,5 @@ getSubnetworkFromIndra <- function(input, package or utilizing the results based on this package. See the LICENSE file for more details." ) - return(list(nodes = nodes, edges = edges)) + return(subnetwork) } diff --git a/R/utils_getSubnetworkFromIndra.R b/R/utils_getSubnetworkFromIndra.R index 4b14fd0..b398ebf 100644 --- a/R/utils_getSubnetworkFromIndra.R +++ b/R/utils_getSubnetworkFromIndra.R @@ -374,6 +374,16 @@ return(list(nodes = nodes, edges = edges)) } +.filterByPtmSite = function(nodes, edges, filter_by_ptm_site) { + if (filter_by_ptm_site && nrow(nodes[!is.na(nodes$Site), ]) > 0) { + ptm_overlap <- calculatePTMOverlapAggregated(edges, nodes) + edges <- edges[ptm_overlap[paste(edges$source, edges$target, edges$interaction, sep = "-")] != "", ] + edges <- edges[!is.na(edges$site),] + nodes <- nodes[nodes$id %in% c(edges$source, edges$target), ] + } + return(list(nodes = nodes, edges = edges)) +} + #' Construct correlation matrix from MSstats #' @param protein_level_data output of dataProcess #' @importFrom tidyr pivot_wider diff --git a/man/getSubnetworkFromIndra.Rd b/man/getSubnetworkFromIndra.Rd index 8722e39..a670d6e 100644 --- a/man/getSubnetworkFromIndra.Rd +++ b/man/getSubnetworkFromIndra.Rd @@ -15,7 +15,8 @@ getSubnetworkFromIndra( sources_filter = NULL, logfc_cutoff = NULL, force_include_other = NULL, - filter_by_curation = FALSE + filter_by_curation = FALSE, + filter_by_ptm_site = FALSE ) } \arguments{ @@ -58,6 +59,10 @@ as "namespace:identifier", e.g. "HGNC:1234" or "CHEBI:4911".} \item{filter_by_curation}{logical, whether to filter out statements that have been curated as incorrect in INDRA. Default is FALSE.} + +\item{filter_by_ptm_site}{logical, whether to filter edges based on whether the +site information from INDRA matches with the PTM site in the input. Default is FALSE. +Only applicable for differential PTM abundance results.} } \value{ list of 2 data.frames, nodes and edges From d3fcc1012e7a1e7f7aa31826295f187dae506275 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Tue, 24 Feb 2026 15:50:17 -0500 Subject: [PATCH 14/17] fix code --- R/getSubnetworkFromIndra.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/getSubnetworkFromIndra.R b/R/getSubnetworkFromIndra.R index 027d426..536efab 100644 --- a/R/getSubnetworkFromIndra.R +++ b/R/getSubnetworkFromIndra.R @@ -64,7 +64,7 @@ getSubnetworkFromIndra <- function(input, input <- .filterGetSubnetworkFromIndraInput(input, pvalueCutoff, logfc_cutoff, force_include_other) .validateGetSubnetworkFromIndraInput(input, protein_level_data, sources_filter, force_include_other) res <- .callIndraCogexApi(input$HgncId, force_include_other) - res <- .filterIndraResponse(res, statement_types, evidence_count_cutoff, sources_filter, filter_by_curation, api_key) + res <- .filterIndraResponse(res, statement_types, evidence_count_cutoff, sources_filter) edges <- .constructEdgesDataFrame(res, input, protein_level_data) edges <- .filterEdgesDataFrame(edges, paper_count_cutoff, correlation_cutoff) nodes <- .constructNodesDataFrame(input, edges) From c7ea894cea6ae692c511d88e4c137057c8e23427 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Tue, 24 Feb 2026 17:31:05 -0500 Subject: [PATCH 15/17] coderabbit comments --- R/getSubnetworkFromIndra.R | 2 +- R/utils_getSubnetworkFromIndra.R | 5 +++-- R/visualizeNetworksWithHTML.R | 2 ++ man/exportNetworkToHTML.Rd | 2 ++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/R/getSubnetworkFromIndra.R b/R/getSubnetworkFromIndra.R index 536efab..09f1f30 100644 --- a/R/getSubnetworkFromIndra.R +++ b/R/getSubnetworkFromIndra.R @@ -69,7 +69,7 @@ getSubnetworkFromIndra <- function(input, edges <- .filterEdgesDataFrame(edges, paper_count_cutoff, correlation_cutoff) nodes <- .constructNodesDataFrame(input, edges) subnetwork = .filterByPtmSite(nodes, edges, filter_by_ptm_site) - subnetwork = .filterByCuration(subnetwork$nodes, subnetwork$edges, filter_by_curation) + subnetwork = .filterByCuration(subnetwork$nodes, subnetwork$edges, evidence_count_cutoff, filter_by_curation) warning( "NOTICE: This function includes third-party software components that are licensed under the BSD 2-Clause License. Please ensure to diff --git a/R/utils_getSubnetworkFromIndra.R b/R/utils_getSubnetworkFromIndra.R index b398ebf..6fb27a0 100644 --- a/R/utils_getSubnetworkFromIndra.R +++ b/R/utils_getSubnetworkFromIndra.R @@ -360,7 +360,7 @@ return(edges) } -.filterByCuration = function(nodes, edges, filter_by_curation) { +.filterByCuration = function(nodes, edges, evidence_count_cutoff, filter_by_curation) { if (filter_by_curation) { incorrect_counts <- numeric(nrow(edges)) for (i in seq_len(nrow(edges))) { @@ -377,7 +377,8 @@ .filterByPtmSite = function(nodes, edges, filter_by_ptm_site) { if (filter_by_ptm_site && nrow(nodes[!is.na(nodes$Site), ]) > 0) { ptm_overlap <- calculatePTMOverlapAggregated(edges, nodes) - edges <- edges[ptm_overlap[paste(edges$source, edges$target, edges$interaction, sep = "-")] != "", ] + keep <- ptm_overlap[paste(edges$source, edges$target, edges$interaction, sep = "-")] + edges <- edges[!is.na(keep) & keep != "", ] edges <- edges[!is.na(edges$site),] nodes <- nodes[nodes$id %in% c(edges$source, edges$target), ] } diff --git a/R/visualizeNetworksWithHTML.R b/R/visualizeNetworksWithHTML.R index 1c13cfa..8fdd79a 100644 --- a/R/visualizeNetworksWithHTML.R +++ b/R/visualizeNetworksWithHTML.R @@ -78,6 +78,7 @@ getRelationshipProperties <- function() { #' @param edges Data frame with edge information including 'target' and 'site' columns #' @param nodes Data frame with node information including 'id' and 'Site' columns #' @return Vector of overlap descriptions for each unique edge (after consolidation) +#' @keywords internal #' @noRd calculatePTMOverlapAggregated <- function(edges, nodes) { if (nrow(edges) == 0) return(character(0)) @@ -1141,6 +1142,7 @@ createEdgeClickHandler <- function() { #' @param edges Data frame with edge information #' @param filename Output HTML filename #' @param displayLabelType Type of label to display ("id" or "hgncName") +#' @param nodeFontSize Font size for node labels (default: 12) #' @param ... Additional arguments passed to exportCytoscapeToHTML() #' @export #' @return Invisibly returns the file path of the created HTML file diff --git a/man/exportNetworkToHTML.Rd b/man/exportNetworkToHTML.Rd index d5f9a7d..ca8f679 100644 --- a/man/exportNetworkToHTML.Rd +++ b/man/exportNetworkToHTML.Rd @@ -22,6 +22,8 @@ exportNetworkToHTML( \item{displayLabelType}{Type of label to display ("id" or "hgncName")} +\item{nodeFontSize}{Font size for node labels (default: 12)} + \item{...}{Additional arguments passed to exportCytoscapeToHTML()} } \value{ From ccb661c7a13d5359221e5e557020e56ca98a19b2 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Tue, 24 Feb 2026 17:39:12 -0500 Subject: [PATCH 16/17] change interaction types to statement types --- R/utils_getSubnetworkFromIndra.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/utils_getSubnetworkFromIndra.R b/R/utils_getSubnetworkFromIndra.R index 6fb27a0..303512d 100644 --- a/R/utils_getSubnetworkFromIndra.R +++ b/R/utils_getSubnetworkFromIndra.R @@ -96,18 +96,18 @@ #' Call INDRA Cogex API and return response #' @param res response from INDRA -#' @param interaction_types interaction types to filter by +#' @param statement_types interaction types to filter by #' @param evidence_count_cutoff number of evidence to filter on for each paper #' @param sources_filter list of sources to filter by. Default is NULL, i.e. no filter #' @return filtered list of INDRA statements #' @importFrom jsonlite fromJSON #' @keywords internal #' @noRd -.filterIndraResponse <- function(res, interaction_types, evidence_count_cutoff, +.filterIndraResponse <- function(res, statement_types, evidence_count_cutoff, sources_filter = NULL) { - if (!is.null(interaction_types)) { + if (!is.null(statement_types)) { res = Filter( - function(statement) statement$data$stmt_type %in% interaction_types, + function(statement) statement$data$stmt_type %in% statement_types, res) } if (!is.null(sources_filter)) { From 7c4e728609ca5ead4d92b52bdf3a5432056a1d7a Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Tue, 24 Feb 2026 17:40:34 -0500 Subject: [PATCH 17/17] add a dot to indicate internal function --- R/utils_getSubnetworkFromIndra.R | 2 +- R/visualizeNetworksWithHTML.R | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/utils_getSubnetworkFromIndra.R b/R/utils_getSubnetworkFromIndra.R index 303512d..a5a717c 100644 --- a/R/utils_getSubnetworkFromIndra.R +++ b/R/utils_getSubnetworkFromIndra.R @@ -376,7 +376,7 @@ .filterByPtmSite = function(nodes, edges, filter_by_ptm_site) { if (filter_by_ptm_site && nrow(nodes[!is.na(nodes$Site), ]) > 0) { - ptm_overlap <- calculatePTMOverlapAggregated(edges, nodes) + ptm_overlap <- .calculatePTMOverlapAggregated(edges, nodes) keep <- ptm_overlap[paste(edges$source, edges$target, edges$interaction, sep = "-")] edges <- edges[!is.na(keep) & keep != "", ] edges <- edges[!is.na(edges$site),] diff --git a/R/visualizeNetworksWithHTML.R b/R/visualizeNetworksWithHTML.R index 8fdd79a..db8b64c 100644 --- a/R/visualizeNetworksWithHTML.R +++ b/R/visualizeNetworksWithHTML.R @@ -80,7 +80,7 @@ getRelationshipProperties <- function() { #' @return Vector of overlap descriptions for each unique edge (after consolidation) #' @keywords internal #' @noRd -calculatePTMOverlapAggregated <- function(edges, nodes) { +.calculatePTMOverlapAggregated <- function(edges, nodes) { if (nrow(edges) == 0) return(character(0)) # Group edges by source-target-interaction to match consolidation logic @@ -154,7 +154,7 @@ consolidateEdges <- function(edges, nodes = NULL) { # Calculate aggregated PTM overlap information if nodes are provided ptm_overlap_map <- if (!is.null(nodes)) { - calculatePTMOverlapAggregated(edges, nodes) + .calculatePTMOverlapAggregated(edges, nodes) } else { NULL }