set.seed(1234)
df <- dplyr::tibble(
g1 = factor(abs(round(rnorm(99, 0, 1)))),
g2 = rep(LETTERS[1:4], c(50, 40, 8, 1)),
e1 = sample(c("P", "N"), 99, replace = TRUE),
e2 = rnorm(99)
)
print(str(df))
print(head(df))
# Compare g1:e1, g1:e2, g2:e1 and g2:e2
x1 <- group_enrichment(df, grp_vars = c("g1", "g2"), enrich_vars = c("e1", "e2"))
x1
# Only compare g1:e1, g2:e2
x2 <- group_enrichment(df,
grp_vars = c("g1", "g2"),
enrich_vars = c("e1", "e2"),
co_method = "wilcox.test",
cross = FALSE
)
x2
# \donttest{
# Visualization
p1 <- show_group_enrichment(x1, fill_by_p_value = TRUE)
p1
p2 <- show_group_enrichment(x1, fill_by_p_value = FALSE)
p2
p3 <- show_group_enrichment(x1, return_list = TRUE)
p3
# }
Run the code above in your browser using DataLab