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+ # #' }
2145setGeneric ("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+ # #' }
4488setGeneric ("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+ # #' }
73144setGeneric ("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+ # #' }
177268setGeneric ("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)
0 commit comments