This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Enhanced Volcano: custom color

Hi everyone,

I just downloaded the EnhancedVolcano package and I was trying to create my custom color scheme. The default color scheme makes DEGs that are above and below the FCCutoff the same color (e.g. red). However, I would like the upregulated and downregulated DEGs to be different colors, so I followed the manual example to create a new vector:

test <- read_csv("DEG.csv") %>% as.data.frame() ## My table contains gene symbol, log2FoldChange, pvalue and padj

keyvals <- ifelse(test$log2FoldChange <= -1 & test$padj<0.01, 'royalblue',  ifelse(test$log2FoldChange >=1 & test$padj<0.01, 'red2', 'black'))

I checked that my 'keyvals' vector is the same length as my 'test' table and there is a color value in every row (no 'NA'). Then when I run this

EnhancedVolcano(test, lab=test$mgi_symbol, x='log2FoldChange',y='padj', xlim=c(-10,10), pCutoff=10e-3, colCustom=keyvals)

I get the following error:

Error: Aesthetics must be either length 1 or the same as the data (20326): colour

I'm quite new to R so I'm not sure what went wrong. Any help (@ Kevin Blighe) will be much appreciated!

rna-seq volcano plot

1 answer

Hello kand3e, how are you?

Could you possibly show the output of:

str(test)
head(test)
str(keyvals)
sessionInfo()

?

Kevin

Thanks! Is test$mgi_symbol NA for everything? Does the plot generate if you use lab=test$row?

Hi Kevin,

'test$mgi_symbol' is not NA for everything, I do have gene symbols for some of the rows (because I only wanted to plot specific genes of interest). The plot generates no problem with the 'lab=test$mgi_symbol' and other customization as long as I don't include the 'colCustom=keyvals'. As soon as I add 'colCustom=keyvals', the error comes out :(

Ah! It works! Thanks so much Kevin! That was so careless of me >w<

Senza problemi / No problem / No hay de que / Problema nenhum

Log in to answer this question.