Skip to content

Commit 83e44a3

Browse files
authored
Merge pull request YuLab-SMU#2 from YuLab-SMU/master
merge from Yulab
2 parents 741157e + f99af64 commit 83e44a3

24 files changed

+646
-361
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 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.995
3+
Version: 1.11.2
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"))
@@ -45,7 +45,7 @@ Suggests:
4545
gridExtra,
4646
ggnewscale,
4747
ggrepel (>= 0.9.0),
48-
ggsymbol,
48+
ggstar,
4949
treeio,
5050
scales,
5151
tidytree

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ PKGSRC := $(shell basename `pwd`)
44

55
all: rd check clean
66

7+
for-release: rd check-dontrun clean
8+
79
alldocs: rd
810

911
rd:
@@ -28,6 +30,11 @@ check: build
2830
cd ..;\
2931
Rscript -e 'rcmdcheck::rcmdcheck("$(PKGNAME)_$(PKGVERS).tar.gz")'
3032

33+
check-dontrun: build
34+
cd ..;\
35+
Rscript -e 'rcmdcheck::rcmdcheck("$(PKGNAME)_$(PKGVERS).tar.gz", args=c("--run-dontrun"))'
36+
37+
3138
check2: build
3239
cd ..;\
3340
R CMD check $(PKGNAME)_$(PKGVERS).tar.gz

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ importFrom(ggplot2,geom_linerange)
6767
importFrom(ggplot2,geom_point)
6868
importFrom(ggplot2,geom_rect)
6969
importFrom(ggplot2,geom_segment)
70+
importFrom(ggplot2,geom_text)
7071
importFrom(ggplot2,geom_tile)
7172
importFrom(ggplot2,geom_violin)
7273
importFrom(ggplot2,geom_vline)

NEWS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
# enrichplot 1.11.1.995
1+
# enrichplot 1.11.2
22

3+
+ update document (2021-1-7, Thu)
4+
+ update `dotplot`: replace `ggsymbol::geom_symbol` with `ggstar::geom_star`(2021-1-6, Wed)
5+
+ add parameter `shadowtext` for three functions: `emapplot`, `emapplot_cluster` and `cnetplot`. (2021-1-5, Tue)
36
+ update `dotplot`: supports the use of shapes and line colors to distinguish groups (2021-1-3, Sun)
47
+ add `treeplot` function (2020-12-29, Tue)
58
+ rename function `get_ww` to `get_similarity_matrix` (2020-12-29, Tue)

R/AllGenerics.R

Lines changed: 133 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,43 @@
55
##' (e.g. GO categories, KEGG pathways)
66
##' @title cnetplot
77
##' @rdname cnetplot
8-
##' @param x enrichment result
9-
##' @param showCategory number of enriched terms to display
10-
##' @param foldChange fold Change
11-
##' @param layout layout of the network
12-
##' @param ... additional parameters
8+
##' @param x Enrichment result.
9+
##' @param showCategory A number or a vector of terms. If it is a number,
10+
##' the first n terms will be displayed. If it is a vector of terms,
11+
##' the selected terms will be displayed.
12+
##' @param foldChange Fold Change of nodes, the default value is NULL.
13+
##' If the user provides the Fold Change value of the nodes,
14+
##' it can be used to set the color of the gene node.
15+
##' @param layout Layout of the map, e.g. 'star', 'circle', 'gem', 'dh', 'graphopt', 'grid', 'mds',
16+
##' 'randomly', 'fr', 'kk', 'drl' or 'lgl'.
17+
##' @param ... Additional parameters
1318
##' @return ggplot object
1419
##' @export
1520
##' @examples
16-
##' library(DOSE)
17-
##' data(geneList)
18-
##' de <- names(geneList)[1:100]
19-
##' x <- enrichDO(de)
20-
##' cnetplot(x)
21+
##' \dontrun{
22+
##' library(DOSE)
23+
##' data(geneList)
24+
##' de <- names(geneList)[1:100]
25+
##' x <- enrichDO(de)
26+
##' x2 <- pairwise_termsim(x)
27+
##' cnetplot(x2)
28+
##' # use `layout` to change the layout of map
29+
##' cnetplot(x2, layout = "star")
30+
##' # use `showCategory` to select the displayed terms. It can be a number of a vector of terms.
31+
##' cnetplot(x2, showCategory = 10)
32+
##' categorys <- c("pre-malignant neoplasm", "intestinal disease",
33+
##' "breast ductal carcinoma", "non-small cell lung carcinoma")
34+
##' cnetplot(x2, showCategory = categorys)
35+
##' # It can also graph compareClusterResult
36+
##' data(gcSample)
37+
##' library(clusterProfiler)
38+
##' library(DOSE)
39+
##' library(org.Hs.eg.db)
40+
##' data(gcSample)
41+
##' xx <- compareCluster(gcSample, fun="enrichGO", OrgDb="org.Hs.eg.db")
42+
##' xx2 <- pairwise_termsim(xx)
43+
##' cnetplot(xx2)
44+
##' }
2145
setGeneric("cnetplot",
2246
function(x, showCategory = 5,
2347
foldChange = NULL, layout = "kk", ...)
@@ -36,11 +60,31 @@ setGeneric("cnetplot",
3660
##' @importFrom methods setGeneric
3761
##' @export
3862
##' @examples
39-
##' library(DOSE)
40-
##' data(geneList)
41-
##' de <- names(geneList)[1:100]
42-
##' x <- enrichDO(de)
43-
##' dotplot(x)
63+
##' \dontrun{
64+
##' library(DOSE)
65+
##' data(geneList)
66+
##' de <- names(geneList)[1:100]
67+
##' x <- enrichDO(de)
68+
##' dotplot(x)
69+
##' # use `showCategory` to select the displayed terms. It can be a number of a vector of terms.
70+
##' dotplot(x, showCategory = 10)
71+
##' categorys <- c("pre-malignant neoplasm", "intestinal disease",
72+
##' "breast ductal carcinoma", "non-small cell lung carcinoma")
73+
##' dotplot(x, showCategory = categorys)
74+
##' # It can also graph compareClusterResult
75+
##' data(gcSample)
76+
##' library(clusterProfiler)
77+
##' library(DOSE)
78+
##' library(org.Hs.eg.db)
79+
##' data(gcSample)
80+
##' xx <- compareCluster(gcSample, fun="enrichGO", OrgDb="org.Hs.eg.db")
81+
##' xx2 <- pairwise_termsim(xx)
82+
##' library(ggstar)
83+
##' dotplot(xx2)
84+
##' dotplot(xx2, shape = TRUE)
85+
##' dotplot(xx2, group = TRUE)
86+
##' dotplot(xx2, x = "GeneRatio", group = TRUE, size = "count")
87+
##' }
4488
setGeneric("dotplot",
4589
function(object, ...)
4690
standardGeneric("dotplot")
@@ -52,24 +96,51 @@ setGeneric("dotplot",
5296
##'
5397
##' This function visualizes gene sets as a network (i.e. enrichment map).
5498
##' Mutually overlapping gene sets tend to cluster together, making it
55-
##' easier for interpretation.
99+
##' easier for interpretation. When the similarity between terms meets
100+
##' a certain threshold (default is 0.2, adjusted by parameter `min_edge`),
101+
##' there will be edges between terms. The stronger the similarity,
102+
##' the shorter and thicker the edges. The similarity between terms is
103+
##' obtained by function `pairwise_termsim`, the details of similarity
104+
##' calculation can be found in its documentation: \link{pairwise_termsim}.
56105
##' @title emapplot
57106
##' @rdname emapplot
58-
##' @param x enrichment result.
59-
##' @param showCategory number of enriched terms to display
60-
##' @param color variable that used to color enriched terms, e.g. pvalue,
61-
##' p.adjust or qvalue
62-
##' @param layout layout of the map
63-
##' @param ... additional parameters
107+
##' @param x Enrichment result.
108+
##' @param showCategory A number or a vector of terms. If it is a number,
109+
##' the first n terms will be displayed. If it is a vector of terms,
110+
##' the selected terms will be displayed.
111+
##' @param color Variable that used to color enriched terms, e.g. 'pvalue',
112+
##' 'p.adjust' or 'qvalue'.
113+
##' @param layout Layout of the map, e.g. 'star', 'circle', 'gem', 'dh', 'graphopt', 'grid', 'mds',
114+
##' 'randomly', 'fr', 'kk', 'drl' or 'lgl'.
115+
##' @param ... Additional parameters
64116
##' @return ggplot object
65117
##' @export
66118
##' @examples
67-
##' library(DOSE)
68-
##' data(geneList)
69-
##' de <- names(geneList)[1:100]
70-
##' x <- enrichDO(de)
71-
##' x2 <- pairwise_termsim(x)
72-
##' emapplot(x2)
119+
##' \dontrun{
120+
##' library(DOSE)
121+
##' data(geneList)
122+
##' de <- names(geneList)[1:100]
123+
##' x <- enrichDO(de)
124+
##' x2 <- pairwise_termsim(x)
125+
##' emapplot(x2)
126+
##' # use `layout` to change the layout of map
127+
##' emapplot(x2, layout = "star")
128+
##' # use `showCategory` to select the displayed terms. It can be a number of a vector of terms.
129+
##' emapplot(x2, showCategory = 10)
130+
##' categorys <- c("pre-malignant neoplasm", "intestinal disease",
131+
##' "breast ductal carcinoma", "non-small cell lung carcinoma")
132+
##' emapplot(x2, showCategory = categorys)
133+
##'
134+
##' # It can also graph compareClusterResult
135+
##' data(gcSample)
136+
##' library(clusterProfiler)
137+
##' library(DOSE)
138+
##' library(org.Hs.eg.db)
139+
##' data(gcSample)
140+
##' xx <- compareCluster(gcSample, fun="enrichGO", OrgDb="org.Hs.eg.db")
141+
##' xx2 <- pairwise_termsim(xx)
142+
##' emapplot(xx2)
143+
##' }
73144
setGeneric("emapplot",
74145
function(x, showCategory = 30, color="p.adjust", layout = "kk", ...)
75146
standardGeneric("emapplot")
@@ -83,14 +154,18 @@ setGeneric("emapplot",
83154
##'
84155
##' This function visualizes gene sets as a grouped network (i.e. enrichment map).
85156
##' Gene sets with high similarity tend to cluster together, making it easier
86-
##' for interpretation.
157+
##' for interpretation. It adds clustering on the basis of emapplot's network graph.
158+
##'
159+
##' For more details, please refer to the documentation of \link{emapplot}.
87160
##' @title emapplot_cluster
88161
##' @rdname emapplot_cluster
89-
##' @param x enrichment result.
90-
##' @param showCategory number of enriched terms to display
91-
##' @param color variable that used to color enriched terms, e.g. pvalue,
92-
##' p.adjust or qvalue
93-
##' @param ... additional parameters
162+
##' @param x Enrichment result.
163+
##' @param showCategory A number or a vector of terms. If it is a number,
164+
##' the first n terms will be displayed. If it is a vector of terms,
165+
##' the selected terms will be displayed.
166+
##' @param color Variable that used to color enriched terms, e.g. 'pvalue',
167+
##' 'p.adjust' or 'qvalue'.
168+
##' @param ... Additional parameters
94169
##' @return ggplot object
95170
##' @export
96171
##' @examples
@@ -125,14 +200,21 @@ setGeneric("emapplot_cluster",
125200
##'
126201
##'
127202
##' This function add similarity matrix to the termsim slot of enrichment result.
203+
##' Users can use the `method` parameter to select the method of calculating similarity.
204+
##' The Jaccard correlation coefficient(JC) is used by default, and it applies to all situations.
205+
##' When users want to calculate the correlation between GO terms or DO terms, they can also choose
206+
##' "Resnik", "Lin", "Rel" or "Jiang" (they are semantic similarity calculation methods from GOSemSim packages),
207+
##' and at this time, the user needs to provide `semData` parameter, which can be obtained through
208+
##' \link{godata} function in GOSemSim package.
128209
##' @title pairwise_termsim
129210
##' @rdname pairwise_termsim
130211
##' @param x enrichment result.
131212
##' @param method method of calculating the similarity between nodes,
132213
##' one of "Resnik", "Lin", "Rel", "Jiang" , "Wang" and
133214
##' "JC"(Jaccard similarity coefficient) methods.
134-
##' @param semData GOSemSimDATA object
135-
##' @param showCategory number of enriched terms to display
215+
##' @param semData GOSemSimDATA object, can be obtained through
216+
##' \link{godata} function in GOSemSim package.
217+
##' @param showCategory number of enriched terms to display, default value is 200.
136218
##' @examples
137219
##' \dontrun{
138220
##' library(clusterProfiler)
@@ -174,6 +256,15 @@ setGeneric("pairwise_termsim",
174256
##' @param ... additional parameter
175257
##' @return ggplot object
176258
##' @export
259+
##' @examples
260+
##' \dontrun{
261+
##' library(clusterProfiler)
262+
##' data(geneList, package = "DOSE")
263+
##' de <- names(geneList)[1:100]
264+
##' yy <- enrichGO(de, 'org.Hs.eg.db', ont="BP", pvalueCutoff=0.01)
265+
##' goplot(yy)
266+
##' goplot(yy, showCategory = 5)
267+
##' }
177268
setGeneric("goplot",
178269
function(x, showCategory = 10, color = "p.adjust",
179270
layout = "sugiyama", geom = "text", ...)
@@ -306,6 +397,12 @@ setGeneric("upsetplot", function(x, ...) standardGeneric("upsetplot"))
306397
##' d <- godata('org.Hs.eg.db', ont="BP")
307398
##' ego2 <- pairwise_termsim(ego, method = "Wang", semData = d)
308399
##' treeplot(ego2, showCategory = 30)
400+
##' # use `hilight = FALSE` to remove ggtree::geom_hilight() layer.
401+
##' treeplot(ego2, showCategory = 30, hilight = FALSE)
402+
##' # use `offset` parameter to adjust the distance of bar and tree.
403+
##' treeplot(ego2, showCategory = 30, hilight = FALSE, offset = 8)
404+
##' # use `offset_tiplab` parameter to adjust the distance of nodes and branches.
405+
##' treeplot(ego2, showCategory = 30, hilight = FALSE, offset_tiplab = 0.3)
309406
##' keep <- rownames(ego2@termsim)[c(1:10, 16:20)]
310407
##' keep
311408
##' treeplot(ego2, showCategory = keep)

R/barplot.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
##' @title barplot
1717
##' @param height enrichResult object
1818
##' @param x one of 'Count' and 'GeneRatio'
19-
##' @param color one of 'pvalue', 'p.adjust', 'qvalue'
19+
##' @param color one of 'pvalue', 'p.adjust' and 'qvalue'
2020
##' @param showCategory number of categories to show
2121
##' @param font.size font size
2222
##' @param title plot title
@@ -33,6 +33,11 @@
3333
##' de <- names(geneList)[1:100]
3434
##' x <- enrichDO(de)
3535
##' barplot(x)
36+
##' # use `showCategory` to select the displayed terms. It can be a number of a vector of terms.
37+
##' barplot(x, showCategory = 10)
38+
##' categorys <- c("pre-malignant neoplasm", "intestinal disease",
39+
##' "breast ductal carcinoma", "non-small cell lung carcinoma")
40+
##' barplot(x, showCategory = categorys)
3641
barplot.enrichResult <- function(height, x="Count", color='p.adjust',
3742
showCategory=8, font.size=12, title="",
3843
label_format=30, ...) {

0 commit comments

Comments
 (0)