From 70f407888ac0d8ebc1fdf6df1903f7cc7978f7ea Mon Sep 17 00:00:00 2001 From: Jacob Mitchell Date: Wed, 29 May 2024 11:38:29 -0400 Subject: [PATCH 1/3] replace pathway column with gene.set Bug found in issue #107. Creating a separate column for "gene.set" apart from the "pathways" column generated by the fgsea and fora functions led to gene set names being associated with the wrong rows. To avoid this kind of issue of redundant columns naming the gene sets that caused this bug, the pathways column is renamed to gene.set then converted to a factor ordered by adjusted p-value. --- R/methods-CogapsResult.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/methods-CogapsResult.R b/R/methods-CogapsResult.R index a3330461..b44bfed8 100755 --- a/R/methods-CogapsResult.R +++ b/R/methods-CogapsResult.R @@ -311,10 +311,10 @@ function(object, gene.sets, method = c("enrichment", "overrepresentation"), ...) amp <- A[,p] names(amp) <- features result <- fgsea::fgsea(pathways = gene.sets, stats = amp, scoreType = "pos") + result <- dplyr::rename(result, gene.set = "pathway") + result <- dplyr::mutate(result,gene.set=forcats::fct_reorder(gene.set, - padj)) result$leadingEdge <- vapply(result$leadingEdge, FUN = toString, FUN.VALUE = character(1)) result$neg.log.padj <- (-10) * log10(result$padj) - result$gene.set <- names(gene.sets) - result <- dplyr::mutate(result,gene.set=forcats::fct_reorder(gene.set, - padj)) return(result) } ) @@ -332,10 +332,10 @@ function(object, gene.sets, method = c("enrichment", "overrepresentation"), ...) pathways = gene.sets, genes = PMlist[[p]], universe = features, maxSize=2038) + result <- dplyr::rename(result, gene.set = "pathway") + result <- dplyr::mutate(result,gene.set=forcats::fct_reorder(gene.set, - padj)) result[["k/K"]] <- result$overlap / result$size result$neg.log.padj <- (-10) * log10(result$padj) - result$gene.set <- names(gene.sets) - result <- dplyr::mutate(result,gene.set=forcats::fct_reorder(gene.set, - padj)) return(result) } ) From 416bd548ff972b99742dad5a152119f8334aff51 Mon Sep 17 00:00:00 2001 From: Jacob Mitchell Date: Wed, 29 May 2024 11:39:43 -0400 Subject: [PATCH 2/3] test significant gene sets Tests for gene set plotting now include a check for a sig_p1 gene set that should be associated with pattern 1. --- tests/testthat/test_getPatternGeneSet.R | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/testthat/test_getPatternGeneSet.R b/tests/testthat/test_getPatternGeneSet.R index ab533b9d..95738218 100644 --- a/tests/testthat/test_getPatternGeneSet.R +++ b/tests/testthat/test_getPatternGeneSet.R @@ -2,6 +2,7 @@ test_that("getPatternGeneSet works on enrichment test", { #set up data(GIST) gs.test <- list( + "sig_p1" = c("Hs.479754", "Hs.491582", "Hs.155591", "Hs.443625", "Hs.170355","Hs.191911"), "gs1" = c("Hs.2", "Hs.4", "Hs.36", "Hs.96", "Hs.202"), "gs2" = c("Hs.699463", "Hs.699288", "Hs.699280", "Hs.699154", "Hs.697294") ) @@ -12,6 +13,7 @@ test_that("getPatternGeneSet works on overrepresentation test", { #set up data(GIST) gs.test <- list( + "sig_p1" = c("Hs.479754", "Hs.491582", "Hs.155591", "Hs.443625", "Hs.170355","Hs.191911"), "gs1" = c("Hs.2", "Hs.4", "Hs.36", "Hs.96", "Hs.202"), "gs2" = c("Hs.699463", "Hs.699288", "Hs.699280", "Hs.699154", "Hs.697294") ) @@ -22,10 +24,15 @@ test_that("plotPatternGeneSet renders a plot for enrichment test", { #set up data(GIST) gs.test <- list( + "sig_p1" = c("Hs.479754", "Hs.491582", "Hs.155591", "Hs.443625", "Hs.170355","Hs.191911"), "gs1" = c("Hs.2", "Hs.4", "Hs.36", "Hs.96", "Hs.202"), "gs2" = c("Hs.699463", "Hs.699288", "Hs.699280", "Hs.699154", "Hs.697294") ) gpgs_res <- getPatternGeneSet(object = GIST.result, gene.sets = gs.test, method = "enrichment") + significant_result <- gpgs_res[[1]][gpgs_res[[1]]$gene.set == "sig_p1",] + + expect_true(significant_result$padj < 0.05) + pl <- plotPatternGeneSet(patterngeneset = gpgs_res, whichpattern = 1, padj_threshold = 1) expect_is(pl$layers[[1]], "ggproto") @@ -36,10 +43,15 @@ test_that("plotPatternGeneSet renders a plot for overrepresentation test", { #set up data(GIST) gs.test <- list( + "sig_p1" = c("Hs.479754", "Hs.491582", "Hs.155591", "Hs.443625", "Hs.170355","Hs.191911"), "gs1" = c("Hs.2", "Hs.4", "Hs.36", "Hs.96", "Hs.202"), "gs2" = c("Hs.699463", "Hs.699288", "Hs.699280", "Hs.699154", "Hs.697294") ) gpgs_res <- getPatternGeneSet(object = GIST.result, gene.sets = gs.test, method = "overrepresentation", threshold = "cut") + significant_result <- gpgs_res[[1]][gpgs_res[[1]]$gene.set == "sig_p1",] + + expect_true(significant_result$padj < 0.05) + pl <- plotPatternGeneSet(patterngeneset = gpgs_res, whichpattern = 1, padj_threshold = 1) expect_is(pl$layers[[1]], "ggproto") From 41826c7bfe05c9a143bbb6398eb7cc1ea57c93cb Mon Sep 17 00:00:00 2001 From: dimalvovs Date: Wed, 29 May 2024 13:06:41 -0400 Subject: [PATCH 3/3] bump version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 81b25bac..bdde3d42 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: CoGAPS -Version: 3.24.0 +Version: 3.24.1 Date: 2024-03-22 Title: Coordinated Gene Activity in Pattern Sets Author: Jeanette Johnson, Ashley Tsang, Jacob Mitchell, Thomas Sherman, Wai-shing Lee, Conor Kelton, Ondrej Maxian, Jacob Carey,