This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Reordering legend labels and changing arrow length in Enhanced Volcano

Hi all, I am very new to R, and I made a volcano plot using enhancedVolcano. It all looks nice, the only problems are:

1) After overriding the color of the points to different groups, it automatically creates the legend and sorts it alphabetically, which I don't want. I tried reordering using legendLabels, and overriding using scale_fill_discrete, but didn't work.

2) I am trying also to make the connectors longer, because some of the points are pretty dense, and are overlapping. But lengthConnectors only changed the arrowhead size, and not the arrow length.

If someone had this problem and found a solution, that would be great!

r enhanced volcano enhancedvolcano

Provide example data, and your current code.

1 answer

Hey David,

For the length of the connectors, you need to modify:

lengthConnectors = unit(0.01, 'npc')

For re-ordering after having used colCustom, that's a very specific level of functionality and I would encourage you to modify it manually after you generate the plot. Otherwise, create a GitHub issue at https://github.com/kevinblighe/EnhancedVolcano/issues

Kevin

Hi Kevin,

I'm running into the same thing as David regarding the order of the legend labels. Do you have any guidance as to how to modify that manually as you suggested? Is there a recommended R or ggplot way of going about that? What I've read so far talks about re-ordering the levels of a df factor but I don't think that applies in this case since the colors are coming from a key-val pairing. Or did you mean more along the lines of modifying the legend in an image editing software after exporting the plot?

Hi, I cannot recall. If changing the order of the key-value pairs does not work, then you may very well have to manually re-order the legend in, e.g., MS Paint.

Log in to answer this question.