Closed aj-kozik closed 1 year ago
Hi, this issue is due to the duplicated terms in test_ego.
library(genekitr)
library(geneset)
library(dplyr)
gs3 <- getReactome(org = "human")
testgenes <- read.csv(file = "~/Downloads/for_R_test/testgenelist.csv", header = TRUE, sep = ",")
## ORA Analysis
id <- testgenes$GeneID
test_ego <- genORA(id,
geneset = gs3,
p_cutoff = 0.05,
q_cutoff = 0.10
)
# check duplicated term
description <- test_ego$Description
dup_term <- description[duplicated(description)] # "Maturation of nucleoprotein"
# get IDs
dup_term_ids <- test_ego %>% filter(Description == dup_term) %>% pull(ID)
# "R-HSA-9683610" "R-HSA-9694631"
You can see both R-HSA-9694631 and R-HSA-9683610 all belong to "Maturation of nucleoprotein". While the Y-axis of the plot does not support duplicated terms.
So the solution is to make the duplicated terms unique. For example, we could combine Reactome IDs with "Maturation of nucleoprotein".
# modify duplicated description
test_ego <- test_ego %>% mutate(Description = if_else(Description %in% dup_term,
paste0(Description,'_',ID),
Description))
plotEnrich(test_ego, plot_type = "bar")
Anyway, I have updated the function in v1.2.3, which could automatically check if duplicated terms exist and give users warning instead of error:
Describe the bug I am trying to create bar plots of my ORA results but keep getting an error in dyplr::mutate()
To Reproduce Steps to reproduce the behavior: using attached testfile 'testgenelist.csv', the following code should reproduce the error
When rlang last trace is run: Error in
dplyr::mutate()
: ℹ In argument:Description = factor(.$Description, levels = .$Description, ordered = T)
. Caused by error inlevels<-
: ! factor level [20] is duplicatedBacktrace: ▆
I expected the barplot to be generated as normal. I haven't had this issue with any other datasets I have analyzed. Inspection of the test_ego result doesn't seem to be impacted either. Dataframe of ORA result (test_ego) screenshot included.
Screenshots testgenelist.csv
Desktop (please complete the following information):
Additional context