kevinblighe / EnhancedVolcano

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

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

Open rana228 opened 12 months ago

rana228 commented 12 months ago

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))
junli1988 commented 9 months ago

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.

rana228 commented 8 months ago

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.