kevinblighe / EnhancedVolcano

Publication-ready volcano plots with enhanced colouring and labeling
399 stars 81 forks source link

Highlighting key variables via custom point sizes - legend? #82

Closed Cajun-data closed 3 years ago

Cajun-data commented 3 years ago

Hello - really enjoying the package! Section 4.13 of your vignette demonstrates how to control point size, but it's not clear if a legend can be produced to describe how the size scales for a given variable. I am mapping point size to a variable which has a few discrete values. Is it possible to generate a separate legend for defining a few point sizes, much like what can be done with custom shapes?

Thanks!

kevinblighe commented 3 years ago

Hi!

Unfortunately, there is no way to do this directly via EnhancedVolcano. I believe I tried to implement it but realised how the various combinations of size, shape, and colour, along with text labeling (geom_text, geom_text_repel, geom_label, and geom_label_repel), made it complicated to implement.

So, pointSize is very much kept outside of the aes(), meaning that it's not picked up as part of the legend.

See for example this line: https://github.com/kevinblighe/EnhancedVolcano/blob/master/R/EnhancedVolcano.R#L408

Kevin

Cajun-data commented 3 years ago

Ok. My workaround at the moment has been to just generate the legend in a separate ggplot and just cut/paste it into the EnhancedVolcano plot (at the appropriate scale).