How to manually sort the legend of gseaplot2 (enrichplot, clusterProfiler) result?
0
0
Entering edit mode
8 weeks ago
fabian • 0

Hello everyone,

I am trying to plot GSEA results using the gseaplot2 function. I want to plot the top5 highest and lowest NES results. The plotting itself works, however the legend is not in the same order as my results, but ordered alphabetically. I would like the legend to be in the same order as the lower part of the plot. Is there a way to automatically or manually do this? For instance by passing a vector with the labels in the right order to the plot object.

gseaplot2(GSEAresults,geneSetID = rev(c(1:5,(length(GSEAresults$Description)-4):(length(GSEAresults$Description))))
      ,pvalue_table = FALSE,subplots = 1:2)

exampleplot

gseaplot2 enrichplot ggplot2 clusterProfiler • 302 views
ADD COMMENT
0
Entering edit mode

ggplot2 automatically order alphabetically, to change that you need to reorder the levels of the element you are plotting. GSEAresults$Description in your case. GSEAresults$Description <- factor(GSEAresults$Description, levels = c("here you rnew order")

ADD REPLY

Login before adding your answer.

Traffic: 2023 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