From d17f1958c2a2313b0daa023ef1136791a1df79e4 Mon Sep 17 00:00:00 2001 From: NelsonGon Date: Mon, 6 Dec 2021 09:17:23 +0100 Subject: [PATCH 1/3] Sort decreasing only for DOSE YuLab-SMU/DOSE#58 --- R/gsea.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/gsea.R b/R/gsea.R index 99c43aa..0783cc0 100644 --- a/R/gsea.R +++ b/R/gsea.R @@ -162,8 +162,10 @@ GSEA_internal <- function(geneList, ...) { by <- match.arg(by, c("fgsea", "DOSE")) - if (!is.sorted(geneList)) + + if (all(!is.sorted(geneList), by == "DOSE")){ stop("geneList should be a decreasing sorted vector...") + } if (by == 'fgsea') { .GSEA <- GSEA_fgsea } else { From 70ea1d95e788fb488439069327b8be3f4dfaef31 Mon Sep 17 00:00:00 2001 From: NelsonGon Date: Mon, 6 Dec 2021 09:41:34 +0100 Subject: [PATCH 2/3] Refactor for code simplicity --- R/gsea.R | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/R/gsea.R b/R/gsea.R index 0783cc0..041f401 100644 --- a/R/gsea.R +++ b/R/gsea.R @@ -163,14 +163,15 @@ GSEA_internal <- function(geneList, by <- match.arg(by, c("fgsea", "DOSE")) - if (all(!is.sorted(geneList), by == "DOSE")){ + .GSEA <- GSEA_fgsea + if (by == 'DOSE') { + if (!is.sorted(geneList)){ stop("geneList should be a decreasing sorted vector...") - } - if (by == 'fgsea') { - .GSEA <- GSEA_fgsea - } else { - .GSEA <- GSEA_DOSE - } + } + .GSEA <- GSEA_DOSE + } + + res <- .GSEA(geneList = geneList, exponent = exponent, From b87be3718f018d0dfa78e9d63509816a9ca936d6 Mon Sep 17 00:00:00 2001 From: NelsonGon Date: Thu, 6 Jan 2022 14:50:01 +0100 Subject: [PATCH 3/3] Rethink sort logic --- R/gsea.R | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/R/gsea.R b/R/gsea.R index b9a945e..8fbc5b3 100644 --- a/R/gsea.R +++ b/R/gsea.R @@ -163,13 +163,14 @@ GSEA_internal <- function(geneList, by <- match.arg(by, c("fgsea", "DOSE")) + + if (by == "fgsea") { .GSEA <- GSEA_fgsea - if (by == 'DOSE') { - if (!is.sorted(geneList)){ - stop("geneList should be a decreasing sorted vector...") - } - .GSEA <- GSEA_DOSE - } + } + else { + if (!is.sorted(geneList)) stop("geneList should be a decreasing sorted vector...") + .GSEA <- GSEA_DOSE + }