Add NES value to GSEA plot
1
2
Entering edit mode
3.6 years ago
rykerklie7 ▴ 30

I am using the gseaplot2 function from enrichplot to mimic the GSEA figure that comes from the software. I would like to add the NES value to the plot, and tried editing the function but results in a error. GSEA

The function used is

  gseaplot2(GSEAobject, geneSetID = 1, title = GSEAobject$Description[1],pvalue_table = TRUE)

I tried editing the gseaplot2 function to include the NES value in the pvalue_table part of the function but the error I get is

Error in x$children[[i]] : no such index at level 1

Source of the function at gseaplot2

R enrichplot clusterprofiler GSEA • 4.1k views
ADD COMMENT
5
Entering edit mode
3.5 years ago
lianchee11 ▴ 50

Hi I have the same concern and then made a solution:

trace("gseaplot2", edit = TRUE)

In the function, look for "if (pvalue_table) {..." and modify the code from:

if (pvalue_table) {
pd <- x[geneSetID, c("Description", "pvalue", "p.adjust")]
rownames(pd) <- pd$Description
pd <- pd[, -1]

to

if (pvalue_table) {
pd <- x[geneSetID, c("NES", "pvalue", "p.adjust")]
rownames(pd) <- ""
pd <- pd[, ]

Hope it helps!

ADD COMMENT
1
Entering edit mode

For those who want to apply this change permanently (i.e will apply when knitting the document), I made a fork with the code change.

remove.packages("enrichplot")
invisible(lapply(paste0('package:', names(sessionInfo()$otherPkgs)), detach, character.only=TRUE, unload=TRUE)) # unload all packages
devtools::install_github("BarryDigby/enrichplot")

Thanks @lianchee11 for the code.

* The pathway description in green font will be omitted from the plot.

ADD REPLY

Login before adding your answer.

Traffic: 2192 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

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

Powered by the version 2.3.6