treeplot: treeplot

Description Usage Arguments Details Value Examples

Description

Functional grouping tree diagram for enrichment result of over-representation test or gene set enrichment analysis.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
treeplot(x, showCategory = 30, color = "p.adjust", label_format = 30, ...)

## S4 method for signature 'enrichResult'
treeplot(x, showCategory = 30, color = "p.adjust", label_format = 30, ...)

## S4 method for signature 'gseaResult'
treeplot(x, showCategory = 30, color = "p.adjust", label_format = 30, ...)

## S4 method for signature 'compareClusterResult'
treeplot(x, showCategory = 5, color = "p.adjust", label_format = 30, ...)

treeplot.enrichResult(
  x,
  showCategory = 30,
  color = "p.adjust",
  nWords = 4,
  nCluster = 5,
  cex_category = 1,
  label_format = 30,
  xlim = NULL,
  fontsize = 4,
  offset = NULL,
  offset_tiplab = 0.35,
  hclust_method = "ward.D",
  group_color = NULL,
  extend = 0.3,
  hilight = TRUE,
  ...
)

treeplot.compareClusterResult(
  x,
  showCategory = 5,
  color = "p.adjust",
  nWords = 4,
  nCluster = 5,
  cex_category = 1,
  split = NULL,
  label_format = 30,
  xlim = NULL,
  fontsize = 4,
  offset = NULL,
  pie = "equal",
  legend_n = 3,
  offset_tiplab = 0.5,
  hclust_method = "ward.D",
  group_color = NULL,
  extend = 0.3,
  hilight = TRUE,
  ...
)

Arguments

x

enrichment result.

showCategory

number of enriched terms to display

color

variable that used to color enriched terms, e.g. pvalue, p.adjust or qvalue

label_format

a numeric value sets wrap length, alternatively a custom function to format axis labels.

...

additional parameters

nWords

The number of words in the cluster tags.

nCluster

The number of clusters, the default value is 5.

cex_category

Number indicating the amount by which plotting category. nodes should be scaled relative to the default.

xlim

Limits for the x axes, e.g. c(0, 40). If the picture is not displayed completely, the user can increase this value.

fontsize

The size of text, default is 4.

offset

Distance bar and tree, offset of bar and text from the clade.

offset_tiplab

Tiplab offset, the bigger the number, the farther the distance between the node and the branch. The default value is 0.35.

hclust_method

Method of hclust. This should be (an unambiguous abbreviation of) one of "ward.D", "ward.D2", "single", "complete", "average" (= UPGMA), "mcquitty" (= WPGMA), "median" (= WPGMC) or "centroid" (= UPGMC).

group_color

A vector of group colors, the length of the vector should be the same as nCluster.

extend

Numeric, extend the length of bar, default is 0.3.

hilight

Logical value, if TRUE(default), add ggtree::geom_hilight() layer.

split

Separate result by 'category' variable.

pie

Proportion of clusters in the pie chart, one of 'equal' (default) and 'Count'.

legend_n

Number of circle in legend, the default value is 3.

Details

This function visualizes gene sets as a tree. Gene sets with high similarity tend to cluster together, making it easier for interpretation.

Value

ggplot object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## Not run: 
    library(clusterProfiler)
    library(org.Hs.eg.db)
    library(enrichplot)
    library(GOSemSim)
    library(DOSE)
    data(geneList)
    gene <- names(geneList)[abs(geneList) > 2]
    ego <- enrichGO(gene  = gene,
        universe      = names(geneList),
        OrgDb         = org.Hs.eg.db,
        ont           = "BP",
        pAdjustMethod = "BH",
        pvalueCutoff  = 0.01,
        qvalueCutoff  = 0.05,
        readable      = TRUE)
    d <- godata('org.Hs.eg.db', ont="BP")
    ego2 <- pairwise_termsim(ego, method = "Wang", semData = d)
    treeplot(ego2, showCategory = 30)
    # use `hilight = FALSE` to remove ggtree::geom_hilight() layer.
    treeplot(ego2, showCategory = 30, hilight = FALSE)
    # use `offset` parameter to adjust the distance of bar and tree.
    treeplot(ego2, showCategory = 30, hilight = FALSE, offset = 8)
    # use `offset_tiplab` parameter to adjust the distance of nodes and branches.
    treeplot(ego2, showCategory = 30, hilight = FALSE, offset_tiplab = 0.3)
    keep <- rownames(ego2@termsim)[c(1:10, 16:20)]
    keep
    treeplot(ego2, showCategory = keep)
    treeplot(ego2, showCategory = 20, 
        group_color = c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442"))
   
## End(Not run)

GuangchuangYu/enrichplot documentation built on Aug. 31, 2021, 7:48 p.m.