From 4973d7dab4817800468078a2822aebc8989a2a07 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Thu, 30 Apr 2026 17:49:54 -0400 Subject: [PATCH 1/2] fix bug for inf fc --- R/utils_getSubnetworkFromIndra.R | 2 ++ .../test-utils_getSubnetworkFromIndra.R | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/R/utils_getSubnetworkFromIndra.R b/R/utils_getSubnetworkFromIndra.R index ef14ef2..089ff93 100644 --- a/R/utils_getSubnetworkFromIndra.R +++ b/R/utils_getSubnetworkFromIndra.R @@ -166,6 +166,8 @@ infinite_fc_proteins <- NULL if (include_infinite_fc) { infinite_fc_proteins <- input[is.infinite(input$log2FC), ] + } else { + input <- input[!is.infinite(input$log2FC), ] } input <- input[!is.na(input$adj.pvalue),] diff --git a/tests/testthat/test-utils_getSubnetworkFromIndra.R b/tests/testthat/test-utils_getSubnetworkFromIndra.R index afd76db..a3e15b9 100644 --- a/tests/testthat/test-utils_getSubnetworkFromIndra.R +++ b/tests/testthat/test-utils_getSubnetworkFromIndra.R @@ -196,6 +196,38 @@ describe(".filterGetSubnetworkFromIndraInput", { ) expect_true("D" %in% result$Protein) }) + + test_that(".filterGetSubnetworkFromIndraInput excludes infinite FC proteins with adj.pvalue=0 when include_infinite_fc is FALSE", { + # MSstats sets adj.pvalue=0 for infinite FC proteins; they must still be excluded + input <- data.frame( + Protein = c("A", "B", "D"), + log2FC = c(3, -3, Inf), + adj.pvalue = c(0.01, 0.01, 0), + stringsAsFactors = FALSE + ) + result <- MSstatsBioNet:::.filterGetSubnetworkFromIndraInput( + input, pvalueCutoff = 0.05, logfc_cutoff = NULL, + force_include_other = NULL, include_infinite_fc = FALSE, direction = "both" + ) + expect_false("D" %in% result$Protein) + }) + + test_that(".filterGetSubnetworkFromIndraInput includes infinite FC protein via force_include_other even when include_infinite_fc is FALSE", { + input <- cbind( + data.frame( + Protein = c("A", "B", "D"), + log2FC = c(3, -3, Inf), + adj.pvalue = c(0.01, 0.01, 0), + stringsAsFactors = FALSE + ), + HgncId = c("1", "2", "4") + ) + result <- MSstatsBioNet:::.filterGetSubnetworkFromIndraInput( + input, pvalueCutoff = 0.05, logfc_cutoff = NULL, + force_include_other = c("HGNC:4"), include_infinite_fc = FALSE, direction = "both" + ) + expect_true("D" %in% result$Protein) + }) test_that(".filterGetSubnetworkFromIndraInput filters by direction up", { result <- MSstatsBioNet:::.filterGetSubnetworkFromIndraInput( From d1d3178ffa7b5b2c4da400c25c485aecc3a40411 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Thu, 30 Apr 2026 23:25:34 -0400 Subject: [PATCH 2/2] adjust infinite fold change filter to only happen if log2FC is a column --- .Rbuildignore | 2 ++ .gitignore | 1 + R/utils_getSubnetworkFromIndra.R | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.Rbuildignore b/.Rbuildignore index cc0e547..8e51b6c 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -7,3 +7,5 @@ ^docs$ ^pkgdown$ ^\.github$ +^\.positai$ +^\.claude$ diff --git a/.gitignore b/.gitignore index 8960620..047cf71 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ /doc/ /Meta/ docs +.positai diff --git a/R/utils_getSubnetworkFromIndra.R b/R/utils_getSubnetworkFromIndra.R index 089ff93..760b1f6 100644 --- a/R/utils_getSubnetworkFromIndra.R +++ b/R/utils_getSubnetworkFromIndra.R @@ -167,7 +167,9 @@ if (include_infinite_fc) { infinite_fc_proteins <- input[is.infinite(input$log2FC), ] } else { - input <- input[!is.infinite(input$log2FC), ] + if ("log2FC" %in% colnames(input)) { + input <- input[!is.infinite(input$log2FC), ] + } } input <- input[!is.na(input$adj.pvalue),]