Agree with this answer. I would create an extra column in my dataframe that marks the label size (if any) then pass that vector to the labsize function while plotting.
I was wondering if it is possible to plot different font sizes for the labels in an EnhancedVolcano plot
I tried it with
..
labSize = c(ifelse(test = topG %in% "GAPDH", 3,1)),
..
and also with
labSize = c(ifelse(test = topG == "GAPDH", 3,1)),
the first one does increase the size of one label, but the wrong one, the second option doesn't do anything to the label size.
P.S. topG are the labels I want to show ( topG <- na.omit(c("GAPDH", resT[1:50,"gene_name"])))
The labSize vector created is of length 50 with the numbers 3,1,1,1,1,1,... Not sure, how to make the function recognize which gene name I won't to highlight.
1 answer
Supplying an integer vector of sizes that exactly matches the order of the input variable specified by lab should, theoretically, work AOK. I think that you may just want to test whether your code is doing exactly what you think:
c(ifelse(test = topG %in% "GAPDH", 3,1))
Kevin
Thanks Kevin Blighe for the answer.
This is the complete command I use (I remove everything which is not important for the function itself)
t<- EnhancedVolcano(toptable = resT[,1:2],
lab = resT$gene_name,
selectLab = topG,
x = "log2FoldChange",
y = "padj",
labSize = c(ifelse(test = topG %in% "GAPDH", 3,1)),
shape = c(1),
pointSize = 0.5,
legendPosition = "right",
legendLabels = c('NS', expression(~log[2]~FC>=1),pval, expression(adj.-p-value~and~log[2]~FC)),
legendLabSize = 5,
maxoverlapsConnectors = Inf
)
resT is the modified results table from DESeq2, topG is a character vector with ~50 gene names
> head(resT)
log2FoldChange padj gene_name
ENSMUSG00000026031 2.781757 0 Cflar
ENSMUSG00000026458 -4.712461 0 Ppfia4
ENSMUSG00000016494 -6.741387 0 Cd34
ENSMUSG00000026833 -3.280005 0 Olfm1
ENSMUSG00000012350 6.230198 0 Ehf
ENSMUSG00000040061 -2.936301 0 Plcb2
> head(topG)
[1] "GAPDH" "Cflar" "Ppfia4" "Cd34" "Olfm1" "Ehf"
The ifelse clause creates the correct vector and put the correct values where they should be
> c(ifelse(test = topG %in% "GAPDH", 3,1))
[1] 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
`
But EnhancedVolcano regards the labelling differently and just assign the vector of names from the resT input table. It therefore increase the size of the first element of the resT table and not the first element of the character vector topG.
I could solve the problem with changing the ifelse clause to that:
resT[resT$gene_name %in% topG,"gene_name"] == "GAPDH"
This is likely because the topG vector and resT dataframe have genes in different orders. In general, it's good practice to keep all of your plotting aesthetics relative to your input dataframe, hence the suggestion of making the label size its own column in the resT object.
Log in to answer this question.