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 ef14ef2..760b1f6 100644 --- a/R/utils_getSubnetworkFromIndra.R +++ b/R/utils_getSubnetworkFromIndra.R @@ -166,6 +166,10 @@ infinite_fc_proteins <- NULL if (include_infinite_fc) { infinite_fc_proteins <- input[is.infinite(input$log2FC), ] + } else { + if ("log2FC" %in% colnames(input)) { + 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(