kevinblighe / EnhancedVolcano

Publication-ready volcano plots with enhanced colouring and labeling
397 stars 81 forks source link

make labCol order consistent with selectLabs #108

Open TianyiShi2001 opened 1 year ago

TianyiShi2001 commented 1 year ago

Currently, when we have selectLab and labCol with multiple values, the order of the colors is not consistent with selectLab. An example (extended from the first example in the vignette):

library('DESeq2')
library(EnhancedVolcano)
library(airway)
data(airway)

dds <- DESeqDataSet(airway, design = ~ cell + dex)
dds <- DESeq(dds, betaPrior=FALSE)
res <- results(dds,
               contrast = c('dex','trt','untrt'))
res <- lfcShrink(dds,
                 contrast = c('dex','trt','untrt'), res=res, type = 'normal')

EnhancedVolcano(res,
                lab = rownames(res),
                x = 'log2FoldChange',
                y = 'pvalue', selectLab = c('ENSG00000125148', 'ENSG00000000419'),
                labCol = c('brown', 'gray'))
スクリーンショット 2022-12-13 14 57 00

This PR resolves this issue by reordering the toptable subset according to the order of selectLab before plotting the labels.

Also I did some refactoring to minimize repetitions.