plot_volc: Create volcano plot

Description Usage Arguments Examples

View source: R/plot_volc.R

Description

Reads a data frame and plots fold difference and p-value in a volcano plot. P-values can be calculated using calc_ttest_padj and fold change (log2 of fold change) using calc_fold_change. Column names for p-value and log2_fold difference is matched based on character matched with p_val and fold_change arguments. Thresholds can be modified using fold_threshold and p_val_threshold arguments. Plot parameters are added in the plot_config list. Protein annotation (e.g. gene names) can be added. If annotation is not included in the data frame, you can use append_cols_df function to add extra columns in your dataset and then continue with plotting. The processed dataset of plot_volc function can be saved in an object (see example).

Usage

1
2
3
4
5
6
plot_volc(x, p_val, fold_change, fold_threshold = 2, p_val_threshold = 0.05,
  plot_config = list(col = c("blue", "red", "grey"), point_size = 1, xlim =
  c(-4, 4), ylim = c(0, NA), xlab = "Log2 fold change A/B", ylab =
  "-log p-value", title =
  "Differentially abundant proteins between groups A and B", show_labs = FALSE,
  lab_lines = FALSE, labs_size = 2, labs_id = "Gene.names...primary.."))

Arguments

x

Data frame containing p-values and calculated fold_change. If fold change is not calculated use calc_fold_change function first and use the output.

p_val

Character string for the identification of the column containing p-values. Only one column should match.

fold_change

Character string for the identification of the column containing log2_fold change values. Only one column should match.

fold_threshold

Threshold for fold difference. Default is 2. You don<e2><80><99>t have to calculate the log2 value of the threshold.

p_val_threshold

Threshold for t-test p-value. Default is 0.05.

plot_config

List of plot parameters (see usage):
col: vector containing the colors for proteins with significant abundance
in group A, B and non-significant. point_size: Point size.
xlim: limits for the x-axis.
ylim: limits for the y-axis.
xlab: Title for the x axis. Default is "Log2 fold change A/B".
ylab: Title for the y-axis. Default is "-log p-value".
title: Plot title. Default is "Differentially abundant proteins between groups A and B".
show_labs: Logical with default value FALSE. If switched to TRUE text annotation defined by the labs_id element (see below) will be added in differentially abundant points.
lab_lines: Logical with default value FALSE. If switched to TRUE, connecting lines between individual points and labels will appear. Uses function from ggrepel package.
It because of the complexity due to labeling, it is advised first to see the number of differentially abundant proteins and then replot the graph with text annotation.
labs_size: Size of the text annotation. Default is 2.
labs_id: Column containing text annotation, like gene names. Default value is <e2><80><9c>Gene.names...primary..<e2><80><9d>. Gene names can be downloaded from Uniprot and merged using append_cols_df function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
p_val <- "pValue"
fold_change <- "log2_fold_change_AB"
plot_config <- list(col = c("blue", "red", "grey"),
                   point_size = 2,
                   xlim = c(-4, 4),
                   ylim = c(0, NA),
                   xlab = "Log2 fold change A/B",
                   ylab = "-log p-value",
                   title = "DA proteins between groups A and B",
                   show_labs = TRUE,
                   lab_lines = TRUE,
                   labs_size = 2,
                   labs_id = "Gene.names...primary..")

my_graph_data <- plot_volc(x = data,
                          p_val = p_val,
                          fold_change = fold_change,
                          fold_threshold = 1.5,
                          p_val_threshold = 0.05,
                          plot_config = plot_config)

write.csv(my_graph_data, file = <e2><80><9c>my_graph_data.csv<e2><80><9d>, row.names = FALSE)

tkostas/komics documentation built on May 24, 2019, 7:31 a.m.