Volcano plot
Description
This is a function to create a volcano plot. When several coefficients are
used, multiple plots side by side are returned.
Usage
daVolcanoPlot(
input,
coef = NULL,
coefLabel = NULL,
featuresIdVar = character(),
featuresVar = featuresIdVar,
fdr = 0.05,
logFCrange = NULL,
xlab = "logFC",
ylab = "-log10(p-value)",
axesCex = 1,
axesTitleCex = 1.1,
title = NULL,
titleCex = 1.1,
legendPosition = c("right", "bottom", "none"),
legendTitleCex = 1,
legendCex = 0.8,
facetCex = 1,
facetColor = "black",
facetNCol = grDevices::n2mfrow(length(coef))[2],
topGenes = 0,
topGenesVar = featuresIdVar,
topGenesCex = 2.5,
returnTopGenes = FALSE,
genesToHighlight = NULL,
genesToHighlightVar = featuresIdVar,
genesToHighlightCex = 2.5,
genesToHighlightThresholdPValue = 1,
genesToHighlightThresholdLogFC = NULL,
colorVar = character(),
color = if (length(colorVar) > 0) character() else "black",
shapeVar = character(),
shape = if (length(shapeVar) > 0) numeric() else 19,
alphaVar = character(),
alpha = if (length(alphaVar) > 0) numeric() else 0.4,
alphaRange = numeric(),
sizeVar = character(),
size = if (length(sizeVar) > 0) numeric() else 2,
sizeRange = numeric(),
additionalThresholdsAdjPValue = NULL,
typePlot = c("static", "interactive"),
...
)
daVolcanoPlot(
input,
coef = NULL,
coefLabel = NULL,
featuresIdVar = character(),
featuresVar = featuresIdVar,
fdr = 0.05,
logFCrange = NULL,
xlab = "logFC",
ylab = "-log10(p-value)",
axesCex = 1,
axesTitleCex = 1.1,
title = NULL,
titleCex = 1.1,
legendPosition = c("right", "bottom", "none"),
legendTitleCex = 1,
legendCex = 0.8,
facetCex = 1,
facetColor = "black",
facetNCol = grDevices::n2mfrow(length(coef))[2],
topGenes = 0,
topGenesVar = featuresIdVar,
topGenesCex = 2.5,
returnTopGenes = FALSE,
genesToHighlight = NULL,
genesToHighlightVar = featuresIdVar,
genesToHighlightCex = 2.5,
genesToHighlightThresholdPValue = 1,
genesToHighlightThresholdLogFC = NULL,
colorVar = character(),
color = if (length(colorVar) > 0) character() else "black",
shapeVar = character(),
shape = if (length(shapeVar) > 0) numeric() else 19,
alphaVar = character(),
alpha = if (length(alphaVar) > 0) numeric() else 0.4,
alphaRange = numeric(),
sizeVar = character(),
size = if (length(sizeVar) > 0) numeric() else 2,
sizeRange = numeric(),
additionalThresholdsAdjPValue = NULL,
typePlot = c("static", "interactive"),
...
)
Arguments
input |
model or a list with top tables named with coefficients.
For model: object of class MArrayLM
(linear model, see eBayes), DGELRT
(see edgeR) or DESeqResults (see DESeq2) are supported.
See more details on the top table format in section:
Top table format.
|
coef |
character, coefficient names.
|
coefLabel |
character vector of labels or a function to transform
existing labels.
|
featuresIdVar |
column name with feature ids (should be unique).
If not specified, row names are used. featuresIdVar is used to
label topGenes unless topGenesVar is specified.
|
featuresVar |
column name with feature ids to label; used for extra
labels if typePlot is 'interactive'.
|
fdr |
threshold considered for significance, NULL by default.
|
logFCrange |
numeric, two values (upper and lower bounds for logFC).
|
xlab |
x-axis title, NULL by default.
|
ylab |
y-axis title, NULL by default.
|
axesCex |
cex for the axis text.
|
axesTitleCex |
cex for the axis title.
|
title |
plot title, NULL by default.
|
titleCex |
cex for the plot title.
|
legendPosition |
legend position ("right", "bottom", "none").
If 'none', no legend is shown.
|
legendTitleCex |
cex for the legend title.
|
legendCex |
cex for the legend text.
|
facetCex |
cex for the facets if multiple plot are used.
|
facetColor |
color for the text of the facets
|
facetNCol |
number of columns in facets, by default the function
n2mfrow is used to.
|
topGenes |
numeric, number of top genes with highest logFC or p-value
to highlight in the plot for each considered coefficient, 0 by default.
|
topGenesVar |
column name with feature identifier to label topGenes
|
topGenesCex |
cex for topGenes labels
|
returnTopGenes |
logical, if TRUE (FALSE by default), return a list
with the top genes highlighted in the plot.
|
genesToHighlight |
string with identifiers of the genes to highlight,
NULL by default. The gene identifiers should correspond to the variable
specified in genesToHighlightVar, and be contained among the column
names of the output of the topTable function from limma.
|
genesToHighlightVar |
column name with the genes to highlight.
Same as featuresIdVar by default.
|
genesToHighlightCex |
cex for genesToHighlight
|
genesToHighlightThresholdPValue |
numeric, if specified (1 by default)
keep among the genes to highlight, the genes which have a raw p-value lower
(strict) than this threshold for at least one of the coefficient considered.
|
genesToHighlightThresholdLogFC |
numeric, if specified (NULL by default)
keep among the genes to highlight, the genes which have an absolute log FC
higher (strict) than this threshold for at least one of the coefficient
considered.
|
colorVar |
(optional) string with column name containing variable used
for coloring. If not specified, coloring is based on the adjusted p-values.
|
color |
color palette, only used if colorVar is specified.
|
shapeVar |
(optional) string with column name containing variable used
for shaping. If not specified, only points are used.
|
shape |
shape palette, only used if shapeVar is specified.
|
alphaVar |
column name used for the transparency, empty by default.
|
alpha |
character or factor with specified transparency(s) for the
points, replicated if needed. By default: '1' if alphaVar is not specified.
|
alphaRange |
transparency (alpha) range used in the plot, possible only
if the alphaVar is 'numeric' or 'integer'.
|
sizeVar |
column name used for the size, empty by default.
|
size |
character or factor with specified size(s) (cex) for the points,
replicated if needed. This is used only if sizeVar is empty.
By default: '2.5' if sizeVar is not specified and
default ggplot size(s) otherwise
|
sizeRange |
size (cex) range used in the plot,
possible only if the sizeVar is 'numeric' or 'integer'
|
additionalThresholdsAdjPValue |
numeric, additional adjusted p-values
thresholds to use for the coloring of the points, and indicated
in the legend.
|
typePlot |
plot type can be one of "static" or "interactive".
|
... |
Extra parameters passed to geom_text_repel to customize
the position of the gene labels.
|
Value
ggplot object or list with ggplot object and top genes highlighted
in the volcano plot (top 10 genes with highest significance and/or highest
logFC) topGenesVar with names featuresIdVar
(if returnTopGenes is set to TRUE)
Author(s)
Laure Cougnaud, Kirsten Van Hoorde, Katarzyna Gorczak
Examples
exampleData <- createExampleData(path = ".", output = "limma")
model <- exampleData$limma
# Simple volcano plot
daVolcanoPlot(input = model, coef = "B.LvsP")
# Specify logFC range
daVolcanoPlot(input = model, coef = "B.LvsP", logFCrange = c(-2, 2))
# Customized aesthetics
daVolcanoPlot(input = model, coef = c("B.LvsP", "L.LvsP"),
coefLabel = c("A", "B"), facetNCol = 2, colorVar = "adj.P.Val")
# Customized gene annotation
model$genes$group <- rep(c("gr A", "gr B", "gr C"), each = 5323)
daVolcanoPlot(input = model, coef = "B.LvsP", colorVar = "group",
color = setNames(c("orange", "red", "blue"), c("gr A", "gr B", "gr C")))
# Facet by variable(s)
coefs <- c("B.LvsP", "L.LvsP", "B.PvsV", "L.PvsV")
coefsLabel <- list(
sub("(.+)\\.(.+)", "\\2", coefs),
sub("(.+)\\.(.+)", "\\1", coefs)
)
daVolcanoPlot(input = model, coef = coefs, coefLabel = coefsLabel,
facetNCol = 4, colorVar = "adj.P.Val")
# see vignette for other examples
exampleData <- createExampleData(path = ".", output = "limma")
model <- exampleData$limma
daVolcanoPlot(input = model, coef = "B.LvsP")
daVolcanoPlot(input = model, coef = "B.LvsP", logFCrange = c(-2, 2))
daVolcanoPlot(input = model, coef = c("B.LvsP", "L.LvsP"),
coefLabel = c("A", "B"), facetNCol = 2, colorVar = "adj.P.Val")
model$genes$group <- rep(c("gr A", "gr B", "gr C"), each = 5323)
daVolcanoPlot(input = model, coef = "B.LvsP", colorVar = "group",
color = setNames(c("orange", "red", "blue"), c("gr A", "gr B", "gr C")))
coefs <- c("B.LvsP", "L.LvsP", "B.PvsV", "L.PvsV")
coefsLabel <- list(
sub("(.+)\\.(.+)", "\\2", coefs),
sub("(.+)\\.(.+)", "\\1", coefs)
)
daVolcanoPlot(input = model, coef = coefs, coefLabel = coefsLabel,
facetNCol = 4, colorVar = "adj.P.Val")