kevinblighe / EnhancedVolcano

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

Legends for pointSize and colCustom #97

Closed nitishkumarmishra closed 2 years ago

nitishkumarmishra commented 2 years ago

Hi Kevin, I am using EnhacedVolcano for the GSEA plot. Where I am using color and pintntSize dynamically. I want to add legends for both colCustom and pointSize simultaneously in my plot.

I am getting legends for colCustom but not for pointSize. How I can get it?

Thanks Nitish

Here is my code, which I am using:: ##################################################################### keyvals <- ifelse( (df_gsea$NES < -1.0) & (df_gsea$p.adjust <= 0.05), 'royalblue', ifelse((df_gsea$NES > 1) & (df_gsea$p.adjust <= 0.05), 'orangered', 'grey4')) keyvals[is.na(keyvals)] <- 'black' names(keyvals)[keyvals == 'orangered'] <- 'Up' names(keyvals)[keyvals == 'grey4'] <- 'Unchanged' names(keyvals)[keyvals == 'royalblue'] <- 'Down'

Sig_path <- df_gsea[abs(df_gsea$NES)>=1 & df_gsea$p.adjust <= 0.05,] Sig_path <- Sig_path$Description

gg <- EnhancedVolcano(df_gsea, lab = rownames(df_gsea), caption = NULL, subtitle = NULL, x = 'NES', y = 'p.adjust', axisLabSize = 18, title = 'GSEA Net Enrichment Score (NES) Plot', xlab = "GSEA Net Enrichment Score", ylab = "-log10(FDR)", colCustom = keyvals, pointSize = c((abs(df_gsea$NES)*abs(-log10(df_gsea$p.adjust)))+1), xlim = c(-4, 4), ylim = c(0, 4), pCutoff = 5e-2, FCcutoff = 1, selectLab = Sig_path, maxoverlapsConnectors = length(Sig_path), legendDropLevels = TRUE, legendLabels = c('Up', 'Down', 'Unchanged'), labSize = 4, labCol = 'black', labFace = 'bold', colAlpha = 1, cutoffLineType = 'blank', cutoffLineCol = 'black', cutoffLineWidth = 0.8, hline = c(5e-2), hlineCol = c('purple'), hlineType = c('dotdash'), hlineWidth = c(1), vline = c(-1, 0, 1), vlineCol = c('purple', 'grey','purple'), vlineWidth = c(1), vlineType = c('dotdash'), gridlines.major = FALSE, gridlines.minor = FALSE, drawConnectors = TRUE, arrowheads = TRUE, widthConnectors = 0.5)

kevinblighe commented 2 years ago

Hi, in EnhancedVolcano, the use of pointSize will never result in a legend being displayed due to the fact that I use pointSize outside of the aesthetic function, i.e., for example:

geom_point(aes(...), size = pointSize) You could try EnhancedVolcano(...) + geom_point(aes(size = pointSize)), if you wish.