Question: Hello everyone!

I am learning to create a volcano plot by using EnhancedVolcano in R.
But I am struggling to color custom points (genes).

**Here is my input file:**

library('EnhancedVolcano')

res <- read.table("text.txt", header=TRUE)
res$gene <- as.character(res$gene)

res object contains:

head(res)
# gene log2foldchange pvalue padj
#1 Cx3cr1 -8.039239 1.29e-118 2.780000e-116
#2 Trem1 -5.258502 3.01e-44 1.770000e-42
#3 Serpina3f 3.202818 2.12e-09 2.400000e-08

Also, I have gene lists which I want to label(able to do it), and color (cannot do it) in "res$gene" object (overlapping):

gene_list <- scan("503-5ptarget.txt", what="", sep="\n")

[1] "gene" "Fam122A" "Ccnd2" "Usp2" "Arl2" "Rab9B" "Dcaf7" "Pom121" "Ccdc42B" "N4Bp1" "Tmem74B" "Akt3"

Now I created this volcano plot by injecting "gene_list" into "res$gene". But the problem was I can "label" overlapped gene, But I "cannot color that point".

aa2 <- EnhancedVolcano(res,
lab = res$gene,
x = 'log2foldchange',
y = 'pvalue',
title = 'test',
subtitle = "test",
pCutoff = FALSE,
FCcutoff = FALSE,
xlim = c(-10, 10),
pointSize = 2.0,
cutoffLineType = 'blank',
selectLab = gene_list,
labCol = 'black',
labFace = 'bold',
colAlpha = 1,
shade = gene_list,
shadeLabel = 'gene list 1',
shadeAlpha = 1/2,
shadeFill = 'red',
shadeSize = 1,
shadeBins = 5,
col = c('grey', 'grey','grey', 'grey'),
drawConnectors = TRUE,
gridlines.major = FALSE,
gridlines.minor = FALSE,
legendVisible = FALSE)

Here is the plot:

[][1]

How can I color these overlapped gene lists? thank you

[1]: http://%3Ca%20href=%22https://ibb.co/92snqsC%22%3E%3Cimg%20src=%22https://i.ibb.co/92snqsC/Rplot.png%22%20alt=%22Rplot%22%20border=%220%22%3E%3C/a%3E

Answer: Aren't you better off building the plot yourself? I don't think it's going to be much more complicated...

Some dummy data:

```
library(data.table) # Not necessary but super-useful
library(ggrepel) # This is to avoid labels overalapping each other
library(ggplot2)

gene_list <- data.table(
gene= c('gene001', 'gene002', 'gene003', 'gene004'),
colour= c('red', 'blue', 'orange', 'violet')
)

set.seed(123)
n <- 1000
res <- data.table(
gene= sprintf('gene%03d', 1:n),
log2foldchange= c(rgamma(n/2, 1, 2), -rgamma(n/2, 1, 2)),
padj= 10^-rgamma(n, 1, 0.1)
)
```

Convert padj to -log10(p) and add colour choice:

```
res[, log10padj := -log10(padj)]

res <- merge(res, gene_list, by= 'gene', all.x= TRUE)
res
gene log2foldchange padj colour log10padj
1: gene001 0.09110855 1.553255e-11 red 10.808757
2: gene002 0.84787557 5.187897e-30 blue 29.285009
3: gene003 0.81044009 1.754765e-15 orange 14.755781
4: gene004 1.22404803 3.007857e-03 violet 2.521743
5: gene005 0.43951396 4.294535e-20 19.367084
---
996: gene995 -0.74794774 8.898109e-04 3.050702
997: gene996 -0.28476577 4.175561e-10 9.379285
998: gene997 -0.09387140 1.521622e-04 3.817693
999: gene998 -0.99570414 1.755187e-02 1.755677
1000: gene999 -0.73455174 2.145441e-12 11.668483
```

Plot with various bells and whistles:

```
gg <- ggplot(data= res, aes(x= log2foldchange, y= log10padj, label= gene)) +
geom_point(colour= 'grey80') +
geom_point(data= res[abs(log2foldchange) > 0.5 & log10padj > 2], colour= 'grey30') +
geom_point(data= res[!is.na(colour)], colour= 'orange') +
geom_vline(xintercept= c(-0.5, 0.5), colour= 'blue', linetype= 'dashed') +
geom_hline(yintercept= 2, colour= 'blue', linetype= 'dashed') +
geom_text_repel(data= res[!is.na(colour)], colour= colour, fontface= 'bold') +
xlab('log2 fold-change') +
ylab('-log10(Padj)') +
theme_classic()
ggsave('tmp.png', width= 12, height= 12, units= 'cm')
```

There may be different and probably better ways of doing it but hoepfully you get the idea...

![enter image description here][1]

[1]: /media/images/cf747acf-228f-4ada-b4d5-e5f4933d