It’s pretty straightforward the question.
I work with an enrichResult created from the enrichDO function. The round function doesn’t work directly, and the dplyr package seems to not work with these objects. I want to round all numerical arguments as if it were a dataframe with different class columns i.e.:
#something similar to this code (this doesn`t work)
df %>% dplyr::mutate_if(is.numeric, round, digits = 3)
Here the data to run possible code
# Simulate data
set.seed(123) # for reproducibility
n <- 10 # number of observations
simulated_data <- data.frame(
ID = paste0("DOID:", sample(1000:9999, n, replace = TRUE)),
Description = paste0("Description", 1:n),
GeneRatio = paste(sample(1:10, n, replace = TRUE), "/", sample(10:20, n, replace = TRUE)),
BgRatio = paste(sample(100:200, n, replace = TRUE), "/", sample(1000:2000, n, replace = TRUE)),
pvalue = runif(n, 0, 1),
p.adjust = runif(n, 0, 1),
qvalue = runif(n, 0, 1),
geneID = paste0("Gene", sample(1:100, n, replace = TRUE))
)
# Load the DOSE package for the enrichResult class
library(DOSE)
# Create an enrichResult object
edo_example <- new("enrichResult", result = simulated_data,
pvalueCutoff = 0.05, pAdjustMethod = "BH", qvalueCutoff = 0.05)