Skip to content

Commit ab4d28f

Browse files
committed
add treeplot
1 parent 7892c23 commit ab4d28f

File tree

6 files changed

+492
-4
lines changed

6 files changed

+492
-4
lines changed

DESCRIPTION

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: enrichplot
22
Title: Visualization of Functional Enrichment Result
3-
Version: 1.11.1.993
3+
Version: 1.11.1.994
44
Authors@R: c(
55
person(given = "Guangchuang", family = "Yu", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6485-8781")),
66
person(given = "Erqiang", family = "Hu", email = "[email protected]", role = "ctb"))
@@ -25,7 +25,8 @@ Imports:
2525
scatterpie,
2626
shadowtext,
2727
GOSemSim,
28-
magrittr
28+
magrittr,
29+
ggtree
2930
Suggests:
3031
clusterProfiler,
3132
dplyr,
@@ -43,7 +44,10 @@ Suggests:
4344
grDevices,
4445
gridExtra,
4546
ggnewscale,
46-
ggrepel (>= 0.9.0)
47+
ggrepel (>= 0.9.0),
48+
treeio,
49+
scales,
50+
tidytree
4751
VignetteBuilder: knitr
4852
License: Artistic-2.0
4953
URL: https://yulab-smu.top/biomedical-knowledge-mining-book/

NAMESPACE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export(heatplot)
2121
export(plot_grid)
2222
export(pmcplot)
2323
export(ridgeplot)
24+
export(treeplot)
2425
export(upsetplot)
2526
exportMethods(cnetplot)
2627
exportMethods(dotplot)
@@ -31,6 +32,7 @@ exportMethods(gseaplot)
3132
exportMethods(heatplot)
3233
exportMethods(pairwise_termsim)
3334
exportMethods(ridgeplot)
35+
exportMethods(treeplot)
3436
exportMethods(upsetplot)
3537
import(GOSemSim)
3638
import(ggraph)
@@ -48,6 +50,7 @@ importFrom(ggplot2,aes)
4850
importFrom(ggplot2,aes_)
4951
importFrom(ggplot2,aes_string)
5052
importFrom(ggplot2,annotation_custom)
53+
importFrom(ggplot2,coord_cartesian)
5154
importFrom(ggplot2,coord_equal)
5255
importFrom(ggplot2,coord_flip)
5356
importFrom(ggplot2,element_blank)
@@ -83,10 +86,12 @@ importFrom(ggplot2,scale_color_discrete)
8386
importFrom(ggplot2,scale_color_gradient)
8487
importFrom(ggplot2,scale_color_gradientn)
8588
importFrom(ggplot2,scale_color_manual)
89+
importFrom(ggplot2,scale_colour_continuous)
8690
importFrom(ggplot2,scale_colour_gradient2)
8791
importFrom(ggplot2,scale_fill_continuous)
8892
importFrom(ggplot2,scale_fill_discrete)
8993
importFrom(ggplot2,scale_fill_gradientn)
94+
importFrom(ggplot2,scale_fill_manual)
9095
importFrom(ggplot2,scale_size)
9196
importFrom(ggplot2,scale_size_continuous)
9297
importFrom(ggplot2,scale_x_continuous)
@@ -109,6 +114,14 @@ importFrom(ggraph,geom_node_label)
109114
importFrom(ggraph,geom_node_point)
110115
importFrom(ggraph,geom_node_text)
111116
importFrom(ggraph,ggraph)
117+
importFrom(ggtree,`%<+%`)
118+
importFrom(ggtree,geom_cladelab)
119+
importFrom(ggtree,geom_inset)
120+
importFrom(ggtree,geom_tiplab)
121+
importFrom(ggtree,geom_tippoint)
122+
importFrom(ggtree,ggtree)
123+
importFrom(ggtree,groupClade)
124+
importFrom(ggtree,nodepie)
112125
importFrom(graphics,barplot)
113126
importFrom(grid,arrow)
114127
importFrom(grid,gpar)

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# enrichplot 1.11.1.993
1+
# enrichplot 1.11.1.994
22

3+
+ add `treeplot` function (2020-12-29, Tue)
34
+ rename function `get_ww` to `get_similarity_matrix` (2020-12-29, Tue)
45
+ move the `emapplot` related functions to emapplot_utilities.R
56
+ fix bug in `emapplot` and `cnetplot` when enrichment result is one line (2020-12-26, Sat)

R/AllGenerics.R

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,54 @@ setGeneric("ridgeplot",
267267
##' @export
268268
setGeneric("upsetplot", function(x, ...) standardGeneric("upsetplot"))
269269

270+
271+
##' Functional grouping tree diagram for enrichment result of
272+
##' over-representation test or gene set enrichment analysis.
273+
##'
274+
##'
275+
##' This function visualizes gene sets as a tree.
276+
##' Gene sets with high similarity tend to cluster together, making it easier
277+
##' for interpretation.
278+
##' @title treeplot
279+
##' @rdname treeplot
280+
##' @param x enrichment result.
281+
##' @param showCategory number of enriched terms to display
282+
##' @param color variable that used to color enriched terms, e.g. pvalue,
283+
##' p.adjust or qvalue
284+
##' @param label_format a numeric value sets wrap length, alternatively a
285+
##' custom function to format axis labels.
286+
##' @param ... additional parameters
287+
##' @return ggplot object
288+
##' @export
289+
##' @examples
290+
##' \dontrun{
291+
##' library(clusterProfiler)
292+
##' library(org.Hs.eg.db)
293+
##' library(enrichplot)
294+
##' library(GOSemSim)
295+
##' library(DOSE)
296+
##' data(geneList)
297+
##' gene <- names(geneList)[abs(geneList) > 2]
298+
##' ego <- enrichGO(gene = gene,
299+
##' universe = names(geneList),
300+
##' OrgDb = org.Hs.eg.db,
301+
##' ont = "BP",
302+
##' pAdjustMethod = "BH",
303+
##' pvalueCutoff = 0.01,
304+
##' qvalueCutoff = 0.05,
305+
##' readable = TRUE)
306+
##' d <- godata('org.Hs.eg.db', ont="BP")
307+
##' ego2 <- pairwise_termsim(ego, method = "Wang", semData = d)
308+
##' treeplot(ego2, showCategory = 30)
309+
##' keep <- rownames(ego2@termsim)[c(1:10, 16:20)]
310+
##' keep
311+
##' treeplot(ego2, showCategory = keep)
312+
##' treeplot(ego2, showCategory = 20,
313+
##' group_color = c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442"))
314+
##' }
315+
setGeneric("treeplot",
316+
function(x, showCategory = 30, color="p.adjust", label_format = 30, ...)
317+
standardGeneric("treeplot")
318+
)
319+
320+

0 commit comments

Comments
 (0)