From c248ecc2ad8b69d89262755b6330cff943ed7e6e Mon Sep 17 00:00:00 2001 From: hsiao yi Date: Mon, 9 Dec 2024 10:10:00 -0500 Subject: [PATCH] make plot_GSEA more compatible to gsea_result data frame generated by other means --- R/enrichment.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/enrichment.R b/R/enrichment.R index 0923704..b9c6cf5 100644 --- a/R/enrichment.R +++ b/R/enrichment.R @@ -66,6 +66,9 @@ GSEA_test <- function(se, col=NULL, database="GO Biological Process", file=NULL, #' @export plot_GSEA <- function(gsea_result, categroies=15) { + if (!"Count" %in% colnames(gsea_result)) { + gsea_result$Count <- str_count(gsea_result$core_enrichment, "/") + } temp <- gsea_result[order(gsea_result$NES, decreasing = T),] ID_selected <- temp[c(1:categroies, (dim(temp)[1]-categroies + 1):dim(temp)[1]),"ID"] temp <- temp[temp$ID %in% ID_selected,]