EnhancedVolcano icon indicating copy to clipboard operation
EnhancedVolcano copied to clipboard

Highlight Key gene with different color and shape, break x-axis

Open rana228 opened this issue 1 year ago • 2 comments

Hi Kevin,

Thank you for developing such an amazing package.

I have been using this for a long time.

I was able to generate the volcano plot but I would also like to place my gene labels on right side instead of on the dots to improve the label visibility. Also as you can see in the plot, Lmo4 gene has high expression so it is placed far from other genes which doesn't look nice. So is there a way to break the axis like in ggbreak pakage to place it closer to rest of the genes.

Could you please help me out with this issue.

Thank you for your help.

Here is the code:

keyvals <- ifelse(
  res$logFC <= -0.3, 'grey',
  ifelse(res$logFC >= 0.3, 'royalblue',
         'black'))
keyvals[is.na(keyvals)] <- 'black'
names(keyvals)[keyvals == 'royalblue'] <- 'UP'
names(keyvals)[keyvals == 'black'] <- 'Neutral'
names(keyvals)[keyvals == 'grey'] <- 'Down'

p1 <- EnhancedVolcano(res,
                lab = rownames(res),
                x = 'logFC',
                y = 'FDR',
                selectLab = c("Tcf7","Socs3","JunB","Lmo4"),
                xlim= c(-1,6),
                title = 'WT versus OE',
                pCutoff = 5e-02,
                FCcutoff = 0.3,
                pointSize = 3,
                labSize = 8,
                #shapeCustom = keyvals.shape,
                #shape = c(6, 4, 2, 11),
                colCustom = keyvals,
                colAlpha = 1,
                legendPosition = 'NULL',
                legendLabSize = 15,
                legendIconSize = 5.0,
                drawConnectors = TRUE,
                widthConnectors = 1,
                arrowheads = FALSE,
                #directionConnectors= "x",
                min.segment.length= 0,
                #max.overlaps = "Inf",
                colConnectors = 'black',
                gridlines.major = TRUE,
                gridlines.minor = FALSE,
                border = 'partial',
                borderWidth = 1,
                borderColour = 'black')


# Modify scale_x_continuous() --------------------------------------------------
p1 + 
  scale_y_continuous(breaks = c(seq(0,30, 5)), # Modify x-axis tick intervals    
                     limits = c(0, 30))

rana228 avatar Sep 02 '23 22:09 rana228

Have you found a way to break the x-axis? I have a similar problem with one knocked-out gene being lower than everything else.

junli1988 avatar Nov 20 '23 16:11 junli1988

Hi @junli1988,

Sorry for the late reply. You can use ggbreak package (https://cran.r-project.org/web/packages/ggbreak/vignettes/ggbreak.html) to break the axis.

rana228 avatar Jan 03 '24 15:01 rana228