2

I like the package EnhancedVolcano. My data is RNAseq and I analyse it with DESeq2. I want to plot the results as a volcanoplot where I highlight a list of genes of my choice picked_genes. I have succeded in changing pointSize and I am using SelectLab to highlight but when I want to give the chosen genes another color I get stuck. I have added a logical vector to my results file specifying which genes to highlight. I have tried

col = ifelse... 

It doesn't work, all dots are grey.

EnhancedVolcano(res_complete,
                lab = res_complete$gene_name,
                x = "log2FoldChange",
                y = "pvalue",
                pCutoff = 10e-3,
                FCcutoff = 1,
                xlim = c(-10, 10),
                ylim = c(0, -log10(10e-12)),
                col = (ifelse(res_complete$picked_genes == T, "forestgreen", "grey60")),
                pointSize = (ifelse(res_complete$picked_genes == T, 5, 0.5)),
                labSize = 2.5,
                selectLab = picked_genes,
                shape =  16,
                shade = res_complete$picked_genes == T,
                shadeFill = "forestgreen",
                shadeSize = 5,
                shadeLabel = res_complete$picked_genes,
                boxedLabels = TRUE,
                title = "DESeq2 results",
                subtitle = "Differential expression HC vs RA",
                caption = "FC cutoff, 1; p-value cutoff, 10e-3",
                legendPosition = "right",
                legendLabSize = 14,
                colAlpha = 0.9,
                drawConnectors = TRUE,
                hline = c(10e-8),
                widthConnectors = 0.2)

I have also tried:

colCustom =ifelse...

But I get an error message...

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

EnhancedVolcano(res_complete,
                lab = res_complete$gene_name,
                x = "log2FoldChange",
                y = "pvalue",
                pCutoff = 10e-3,
                FCcutoff = 1,
                xlim = c(-10, 10),
                ylim = c(0, -log10(10e-12)),
                colCustom = (ifelse(res_complete$picked_genes == T, "forestgreen", "grey60")),
                pointSize = (ifelse(res_complete$picked_genes == T, 5, 0.5)),
                labSize = 2.5,
                selectLab = picked_genes,
                shape =  16,
                shade = res_complete$picked_genes == T,
                shadeFill = "forestgreen",
                shadeSize = 5,
                shadeLabel = res_complete$picked_genes,
                boxedLabels = TRUE,
                title = "DESeq2 results",
                subtitle = "Differential expression HC vs RA",
                caption = "FC cutoff, 1; p-value cutoff, 10e-3",
                legendPosition = "right",
                legendLabSize = 14,
                colAlpha = 0.9,
                drawConnectors = TRUE,
                hline = c(10e-8),
                widthConnectors = 0.2)

Can someone come up with a solution to this problem?

Axeman
  • 32,068
  • 8
  • 81
  • 94
Malin
  • 41
  • 3

1 Answers1

2

I found it, finally I understood it. colCustom needs a pair for each point, a color and a name. I created the matrix keyvals

keyvals <- ifelse(
  res_complet$picked_genes < T, 'grey60',
           'forestgreen')
names(keyvals)[keyvals == 'forestgreen'] <- 'picked'
names(keyvals)[keyvals == 'grey60'] <- 'rest'

` Than I used it to replace the col=

`

EnhancedVolcano(res_complete,
                lab = res_complete$gene_name,
                x = "log2FoldChange",
                y = "pvalue",
                pCutoff = 10e-3,
                FCcutoff = 1,
                xlim = c(-10, 10),
                ylim = c(0, -log10(10e-12)),
                pointSize = (ifelse(res_complete$picked_genes == T, 5, 0.5)),
                labSize = 2.5,
                shape = c(19, 19, 19, 19),
                selectLab = picked_genes,
                boxedLabels = TRUE,
                title = "DESeq2 results",
                subtitle = "Differential expression HC vs RA",
                caption = "FC cutoff, 1; p-value cutoff, 10e-3",
                legendPosition = "right",
                legendLabSize = 14,
                colCustom = keyvals,
                colAlpha = 0.9,
                drawConnectors = TRUE,
                hline = c(10e-8),
                widthConnectors = 0.2)

`

In order to get all points visible I sorted my results dataframe after the logical column res_complete$picked_genes and made the volcano again. Voilá

Malin
  • 41
  • 3