enrichplot icon indicating copy to clipboard operation
enrichplot copied to clipboard

No colors with respect to fold change and no circular plot

Open abeedhakhan opened this issue 5 months ago • 3 comments

Hi,

I am trying to plot the results of enrichGO. Here's the code:

ego <- enrichGO(gene = sig_genes_L_O$ENTREZID, universe = comparison_L_O$ENTREZID, OrgDb = org.Hs.eg.db, ont = "CC", pAdjustMethod = "BH", pvalueCutoff = 0.01, qvalueCutoff = 0.01, readable = TRUE)

geneList <- sig_genes_L_O$Student's T-test Difference L_O names(geneList) <- as.character(sig_genes_L_O$ENTREZID) geneList <- geneList[!is.na(names(geneList)) & !duplicated(names(geneList))] geneList <- sort(geneList, decreasing = TRUE)

print(cnetplot(ego, foldChange=geneList, categorySize="pvalue", showCategory = 5, circular = TRUE, colorEdge = TRUE))

First, here are the warning I see when I try to plot the cnet plot:

Warning messages: 1: In (function (name = waiver(), ..., low = muted("red"), mid = "white", : log-10 transformation introduced infinite values in midpoint. 2: In transformation$transform(x) : NaNs produced 3: In (function (name = waiver(), ..., low = muted("red"), mid = "white", : log-10 transformation introduced infinite values. 4: ggrepel: 377 unlabeled data points (too many overlaps). Consider increasing max.overlaps

And, here is the plot:

Image

Please help me with this, Thanks.

Kind regards, Abeedha

abeedhakhan avatar Aug 30 '25 10:08 abeedhakhan

This post is the more extensive version of the one you made here: https://github.com/YuLab-SMU/clusterProfiler/issues/785 (and which I saw before this one).

Anyway, please check your input geneList. It should be a named numeric vector (see below for an example), and not a data.frame or so.

It is also not clear to me why you only filter your geneList, and not the inputs for enrichGO. I would first filter out the non-annotated genes before 'feeding' the data to any function.

> 
> class(geneList)
[1] "numeric"
> str(geneList)
 Named num [1:12495] 4.57 4.51 4.42 4.14 3.88 ...
 - attr(*, "names")= chr [1:12495] "4312" "8318" "10874" "55143" ...
>

guidohooiveld avatar Sep 11 '25 10:09 guidohooiveld

Thanks a lot for the response.

I use geneList for GSEA analysis usually, and for enrichment I directly use the genes from the data. But yes, you are right, I should also filter the non-annotated genes from that too.

I ran again after filtering for non-annotated genes, but still I am seeing the warning message: Warning message: In (function (name = waiver(), ..., low = muted("red"), mid = "white", : log-10 transformation introduced infinite values in midpoint.

and the geneList is a named numeric vector:

class(geneList) [1] "numeric" str(geneList) Named num [1:7008] 8.59 7.87 7.14 7.13 6.98 ...

  • attr(*, "names")= chr [1:7008] "7398" "5806" "23224" "11161" ...

The way around I have found for this is:

print(cnetplot(ego, layout = igraph::layout_with_kk, foldChange = geneList, circular = TRUE, colorEdge = TRUE) + scale_color_gradient2(low = "blue", mid = "white", high = "red", midpoint = 0) + ggtitle(paste(comp, "CC", sep = " - ")) + theme(axis.text.y = element_text(size = 8), plot.margin = margin(10, 20, 10, 20)))

after this, the log fold change appears colored on the plot.

abeedhakhan avatar Sep 16 '25 07:09 abeedhakhan

Great, happy to hear you got it working!

guidohooiveld avatar Sep 16 '25 11:09 guidohooiveld