From 28d22683c8cc2c9c98c322e9a7f70161cfa6bc81 Mon Sep 17 00:00:00 2001 From: Tarrin Date: Mon, 23 Feb 2026 19:59:55 -0500 Subject: [PATCH] attendance/added test with negative numbers --- MPA/MPA.Rproj | 1 - MPA/R/MPA_utils.R | 2 +- MPA/tests/testthat/test-utils.R | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/MPA/MPA.Rproj b/MPA/MPA.Rproj index fb32829..497f8bf 100644 --- a/MPA/MPA.Rproj +++ b/MPA/MPA.Rproj @@ -1,5 +1,4 @@ Version: 1.0 -ProjectId: 6922b498-8eb0-4d69-a638-8e3ee1fca3c1 RestoreWorkspace: Default SaveWorkspace: Default diff --git a/MPA/R/MPA_utils.R b/MPA/R/MPA_utils.R index 3ef979e..e3ebdec 100644 --- a/MPA/R/MPA_utils.R +++ b/MPA/R/MPA_utils.R @@ -62,7 +62,7 @@ compute_reaction_score <- function(expr_data, reaction_data){ #' @export compute_pathway_score <- function(expr_data, pathway_data){ pert_score <- 0 - # pert_score <- expr_data + pathway_data + #pert_score <- expr_data + pathway_data # compute perturbation score using expression data and pathway data return(pert_score) } diff --git a/MPA/tests/testthat/test-utils.R b/MPA/tests/testthat/test-utils.R index a850d9a..7b76b4e 100644 --- a/MPA/tests/testthat/test-utils.R +++ b/MPA/tests/testthat/test-utils.R @@ -18,6 +18,7 @@ test_that("compute_pathway_score", { }) + test_that("compute_reaction_score", { expr_data <- data.frame(row.names = c("m1","m2","m3"), condition = c(1.4,2,3), @@ -29,3 +30,16 @@ test_that("compute_reaction_score", { expected_score <- 1 expect_equal(compute_reaction_score(expr_data, reaction_data), expected_score) }) + +test_that("compute_reaction_score_negvalues", { + expr_data <- data.frame(row.names = c("m1","m2","m3"), + condition = c(-1.4,-2,-3), + control = c(-3,-4,-5)) + reaction_data <- list(left = data.frame(row.names = c("m155","m20","m30"), + coefficient = c(-1,-1,-1)), + right = data.frame(row.names = c("m1","m2","m13"), + coefficient = c(-1,-1,-1))) + expected_score <- 1 + expect_equal(compute_reaction_score(expr_data, reaction_data), expected_score) +}) +