Enhanced Volcano: custom color
1
0
Entering edit mode
3.8 years ago
kand3e ▴ 60

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 • 2.9k views
ADD COMMENT
1
Entering edit mode
3.8 years ago

Hello kand3e, how are you?

Could you possibly show the output of:

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

?

Kevin

ADD COMMENT
0
Entering edit mode

Hello Kevin,

Thanks for your prompt reply! Here are the output:

str(test) output: https://ibb.co/gmNLsHQ head (test) and str(keyvals) output: https://ibb.co/9qHbWJW sessionInfo() output: https://ibb.co/vJ5Ccyp
https://ibb.co/N6hxnP6 https://ibb.co/mX138ZN https://ibb.co/MkpKF1w

Sorry, I didn't know how to copy and paste all the output messages here ><

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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 :(

ADD REPLY
0
Entering edit mode

oh! I think that you need to also set the names of the keyvals vector. See the example here: https://github.com/kevinblighe/EnhancedVolcano#over-ride-colouring-scheme-with-custom-key-value-pairs

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 2713 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6