clusterProfiler: exclude pathways and add gene names to cnetplot
Entering edit mode
Mr.RB ▴ 20
Last seen 3.1 years ago

Package: clusterProfiler by Guangchuang Yu

Let start with the example code (just the same as from the vignette):


# basic analysis
data(geneList, package="DOSE")
kegg <- gseKEGG(geneList = geneList, organism = 'hsa')

# plotting
cnetplot(kegg, categorySize="pvalue", foldChange=geneList)

I want to change two things in this cnetplot

  1. Exclude pathways in the graph
  2. Providing gene names instead of the IDs


1. Using the example:

head(kegg@result) %>% select(Description, setSize)

                               Description setSize
hsa04510                    Focal adhesion     188
hsa00982 Drug metabolism - cytochrome P450      49
hsa03050                        Proteasome      42
hsa03030                   DNA replication      33
hsa05340          Primary immunodeficiency      34
hsa04151        PI3K-Akt signaling pathway     320

Let's say I do not want the genes for the Focal adhesion in the cnet graph, how can this be accomplished.

2. using the example

Instead of the ids (such as 6891) I want to show the gene names which I provide myself (or maybe this can be done automatically)




clusterprofiler pathway analysis pathways • 3.0k views
Entering edit mode
Guangchuang Yu ★ 1.2k
Last seen 5 weeks ago
China/Guangzhou/Southern Medical Univer…

1. same question posted on​.

please upgrade enrichplot to v >= 1.0.1, and then you can pass selected Pathway Names (selected from the Description column) to showCategory parameter.


2. you can use DOSE::setReadable to translate gene ID to gene symbol.





Entering edit mode

Dear Guangchuang Yu,

Regarding question 1:

The version I currently have is  enrichplot_1.1.1.001  , which is >=1.0.1 as recommended by you. However when I pass a vector of pathway names to the cnetplot command ( like so x <- cnetplot(kegg, showCategory = kegg$Description[-2]) ) it will give this error:

Error in 1:n : NA/NaN argument
In addition: Warning messages:
1: In 1:n : numerical expression has 38 elements: only the first used
2: In V(g)$size[1:n] <- size : NAs introduced by coercion

Can't figure out what I'm doing wrong here.

Regarding question 2:

After re-reading this question I think I wasn't that clear with what I mean. I love that function, however what I meant is that I could pass this to cnetplot. Of course I could convert the ids to the gene names before calling the gseKEGG function, but this will probably interfere with mapping. Therefore, I want to be able to pass the gene names to cnetplot

Entering edit mode
  1. pls use enrichplot v >= 1.0.2 or v >= 1.1.2, which address the issue you reported.

  2. you misunderstand how setReadable works.

## run gseKEGG as usual

kk <- gseKEGG()

## convert gene ID to symbol

kk2 <- setReadable(kk) # refer to man for additional parameters

## plot

Entering edit mode

1. Thankyou! that version seems to work fine

2. The setReadable will of course only work whenever a db is available for the species in question, this is not the case for me. Therefore I mentioned gene names which I provide myself in my question I looked at the code of and thought I could easily mimic the setReadable function like so:

kegg@gene2Symbol <- as.character(
kegg@keytype <- 'auto'
kegg@result <- kegg@result
kegg@readable <- TRUE

However this will still only show the ids (and loses coloring in the network), instead the names I provided in the, is there any way to provide these manually?


Login before adding your answer.

Traffic: 402 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6