How to use 'nudge_x' from 'ggrepel' within 'EnhancedVolcano'?

107 views Asked by At

I'd like to fine tune the volcano plot produced using EnhancedVolcano. It's a great package with lots of customization options. I want to manually make changes to the length of Connectors, specifically, make it longer.

In this question post: Kevin (Thank you for this wonderful package!) shows how the length and other parameters are used in code chunks in EnhancedVolcano. In the EnhancedVolcano vignette, it's shown that some arguments are parsed by the internal ggrepel.

I'd like to call nudge_x from ggrepel (reference) within EnhancedVolcano function. Specifically, how can I use nudge_x = 2 in the code below? I want to use this argument because it lengthens the connectors in ggrepel but I don't know how to do this in EnhancedVolcano function.

Here's my code:

EnhancedVolcano(reordered_b1,
  lab = rownames(reordered_b1),
  FCcutoff = 0.5,
  pCutoff = 0.05,
  
  selectLab = c('Gene1', 'Gene2', 'Gene3', 'Gene4'),
  labSize = 4,
  labCol = 'black',
  labFace = 'bold',
  boxedLabels = F,
  drawConnectors = T,
  widthConnectors = 1,
  lengthConnectors = unit(0, 'npc'),

  shapeCustom = keyvals.shape,
  colCustom = keyvals.color,
  
  colAlpha = .75,
  pointSize = 5,

  title = vpTitle,
  titleLabSize = 10,
  subtitle = NULL,
  legendPosition = 'none',
  caption = NULL,
  ylab = bquote(~-Log[10]~FDR),
  xlab = bquote(~Log[2]~Fold~Change),
  axisLabSize = 10,
  
  xlim = c(-6,6),
  gridlines.major = FALSE,
  gridlines.minor = FALSE,
  border = 'full')

Thank you!

1

There are 1 answers

2
I_O On

You can view the body (source) of EnhancedVolcano or any other function by typing the function name without parentheses and hitting Enter.

The source shows that, while geom_text_repel and geom_text_label of {ggrepel} are used, EnhancedVolcano unfortunately does not accept additional arguments (like, e.g. nudge_x) to pass through to the underlying ggrepel functions (you can also tell from the lack of the special dot-dot-dot argument in the function's description; see ?EnhancedVolcano).