Hi, I have a DEGs file (DEAdf) with log2FC and padjust. I am trying to look at significant dowreguated and upregulated genes in enhanced volcano plot according to my cutoff. To visulize the up and down regulated genes, I customized them into different colors (keyvals), but it only came out with 2 colors.
I attached my code below:
> keyvals <- ifelse(
> (DEAdf$log2FC>1& DEAdf$padjust>=0.05) | (DEAdf$log2FC<-1&DEAdf$padjust>=0.05) , 'forestgreen',
> ifelse(
> DEAdf$log2FC<-1 & DEAdf$padjust<0.05, 'royalblue',
> ifelse(
> DEAdf$log2FC >1 & DEAdf$padjust<0.05, 'red2',
> ifelse(
> DEAdf$log2FC >= -1 & DEAdf$log2FC <= 1 & DEAdf$padjust<0.05 ,'yellow',
> 'grey30'))))
>
> names(keyvals)[keyvals == 'grey30'] <- 'No significant'
> names(keyvals)[keyvals == 'forestgreen'] <- 'Log2 FC'
> names(keyvals)[keyvals == 'yellow'] <- 'Adjusted p-value'
> names(keyvals)[keyvals == 'royalblue'] <- 'Adjusted p-value & Log2 FC
> <-1' names(keyvals)[keyvals == 'red2'] <- 'Adjusted p-value & Log2 FC
> > 1'
>
> library(EnhancedVolcano) mypval=0.05 myfc=2 mypadj=0.05
> mylog2fc=log2(myfc)
>
> EnhancedVolcano(DEAdf,
> lab = DEAdf$idnames,
> x = 'log2FC',
> y = 'padjust',
> xlim = c(min(DEAdf$log2FC, na.rm=TRUE), max(DEAdf$log2FC, na.rm=TRUE)),
> ylim=c(0, max(-log10(DEAdf$padjust), na.rm=TRUE) + 1),
> title="",
> subtitle=comparing,
> pCutoff=mypadj,
> FCcutoff=mylog2fc,
> pointSize = 2.0,
> labSize = 3.0,
> colCustom = keyvals,
> colAlpha = 1,
> xlab = bquote(~Log[2]~ 'fold change'),
> ylab = bquote(~-Log[10]~adjusted~italic(P)),
> legendPosition = 'top',
> legendLabSize = 10,
> legendIconSize = 5.0,
> drawConnectors = F, # Add lines to show more labels
> widthConnectors = 0.2,
> colConnectors = 'grey30') dev.off()
I think my keyvals have some problems: