Volcano: Volcano Plot

Description Usage Arguments Value Author(s) Examples

View source: R/statVisual.R

Description

Volcano plot with the option to label the significant results.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
Volcano(
    resFrame, 
    stats, 
    p.value, 
    group = NULL, 
    xlab = "logFC", 
    ylab = "-log10(p value)", 
    title = NULL, 
    vline.col = "orange", 
    hline.col = "dodgerblue", 
    vline = list(xintercept = c(-1, 1), label = c(-1, 1)), 
    hline = list(
        yintercept = c(-log10(0.05), 
                       -log10(0.05/nrow(resFrame)), 
                       -log10(max(resFrame[p.adjust(resFrame[, p.value], 
                                       method = "fdr") <= 0.05, p.value]))), 
        label = c("p value: 0.05", "Bonferroni: 0.05", "FDR: 0.05")), 
    rowname.var = NULL, 
    point.size = 3, 
    theme_classic = TRUE, 
    addThemeFlag = TRUE,
    ...)

Arguments

resFrame

A data frame stored information about the results, including gene id, statistic (e.g., log fold change, odds ratio), p-value, and significance of a gene.

stats

character. The column name of resFrame that indicates the effect of a gene.

p.value

character. The column name of resFrame that indicates the p-value.

group

character. The column name of resFrame that indicates the significance of a gene.

xlab

x axis label

ylab

y axis label

title

title of the plot

vline.col

color of the vertical lines (default: “orange”)

hline.col

color of the horizontal lines (default: “dodgerblue”)

vline

A list with two elements: “xintercept” and “label”, where the former element is a numeric vector indicating the x-axis location to draw vertical color lines and the latter element is list of labels for the elements in “xintercept”.

hline

A list with two elements: “yintercept” and “label”, where the former element is a numeric vector indicating the y-axis location to draw horizontal color lines and the latter element is list of labels for the elements in “xintercept”.

rowname.var

character. The column name of resFrame that indicates which variable will be used to label the significant results in the volcano plot. The elements of this column for non-significant results should be set to be NA.

point.size

size of data points in the plot.

theme_classic

logical. Use classic background without grids (default: TRUE).

addThemeFlag

logical. Indicates if light blue background and white grid should be added to the figure.

...

other input parameters for facet & theme

Value

A list with 9 elements. data, layers, scales, mapping, theme, coordinates, facet plot_env, and labels.

Author(s)

Wenfei Zhang <Wenfei.Zhang@sanofi.com>, Weiliang Qiu <Weiliang.Qiu@sanofi.com>, Xuan Lin <Xuan.Lin@sanofi.com>, Donghui Zhang <Donghui.Zhang@sanofi.com>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
library(ggrepel)
library(limma)

# load the simulated dataset
data(esSim)
print(esSim)

# expression levels
y = exprs(esSim)
print(dim(y))
print(y[1:2,])

# phenotype data
pDat = pData(esSim)
print(dim(pDat))
print(pDat)

# design matrix
design = model.matrix(~grp, data = pDat)
print(design)

options(digits = 3)

# Ordinary fit
fit <- lmFit(y, design)
fit2 <- eBayes(fit)

# get result data frame
resFrame = topTable(fit2,coef = 2, number = nrow(esSim))
print(dim(resFrame))
print(resFrame[1:2,])
resFrame$sigFlag  =  resFrame$adj.P.Val < 0.05

resFrame$probe  =  rownames(resFrame)
# make sure set NA to genes non-differentially expressed
resFrame$probe[which(resFrame$sigFlag == FALSE)] = NA

print(resFrame[1:2,])
print(table(resFrame$sigFlag, useNA = "ifany"))

statVisual(type = 'Volcano',
           resFrame = resFrame, 
           stats = 'logFC', 
           p.value = 'P.Value', 
           group = 'sigFlag', 
           rowname.var = 'probe', 
           point.size = 1)

Volcano(
  resFrame = resFrame, 
  stats = 'logFC', 
  p.value = 'P.Value', 
  group = 'sigFlag', 
  rowname.var = 'probe', 
  point.size = 1)

statVisual documentation built on Feb. 21, 2020, 1:08 a.m.