volcanoplot: Make a VolcanoPlot

View source: R/DEplots.R

volcanoplotR Documentation

Make a VolcanoPlot

Description

Using DESeq2 results, make a volcanoplot

Usage

volcanoplot(
  results,
  metadata,
  contrast,
  condition1,
  condition2,
  colors,
  pval_thres,
  lfc_thres,
  lfclimit,
  use_padj,
  pointsize,
  outliergene_pointsize,
  outliergene_shape,
  repeltextsize,
  change_gene_label,
  gene_label_equivalency
)

Arguments

results

dataframe, with column names similar to the output of DESeq2::results() function

metadata

dataframe, for coloring samples using a consistently set color scheme. metadata is a dataframe similar to coldata used in DESEQ2; include a contrast column and colors column

contrast

character string. name of contrast column in metadata. default will search for "Conditions"

condition1

character string. will be used to find the corresponding contrast-color pairing for upregulated genes

condition2

character string. will be used to find the corresponding contrast-color pairing for downregulated genes

colors

character vector of length two with string names or codes of colors. if not using metadata-based coloring, will use this input or default to red/blue.

pval_thres

numeric, alpha value cutoff for significant genes. default = 0.05

lfc_thres

numeric, logFC cutoff for significant genes, will be symmetric on both sides. default = 0

lfclimit

numeric, lofFC cutoff for outlier genes, will be symmetric on both sides. default = 15

use_padj

T/f, default = T. Use adjustec p-value (passed as df,'padj') for y axis and coloring of significant genes.

pointsize

numeric, point size of graph, passed to geom_point, default = 0.5

outliergene_pointsize

numeric, point size of logFC outlier genes, default = 2

outliergene_shape

numeric, code for shape symbol of logFC outlier genes, default = 6, which is a triangle

repeltextsize

numeric, size of repel text gene labels, default is 2

change_gene_label

T/F, whether to change gene labels, defautl F

gene_label_equivalency

data.frame, if change_gene_label is set to T, need to provide a data.frame with two columns, first column with current gene labels (rownames of res) and second column with gene labels you want to plot as labels. Useful for when you have res with IDs but want to show gene symbols.

Details

color can be set with colors or passed using metadata. the latter is encouraged, in keeping with setting a color scheme at the start and keeping it consistent in all analysis.

Value

a ggplot2 object.

Examples



With default colors (red up, blue down):
volcanoplot(results)

With set colors:
volcanoplot(results, colors = c('Purple', 'Pink'))

With different labels, for example if your results have EnsemblIDs but you want to show gene symbols:
volcanoplot(results, change_gene_label = T, gene_label_equivalency = gene_name_df)

where gene_name_df is a data.frame with first two columns like this:
GeneLabelsNum  Gene SymbolsLetter
1              A
2              B
3              C

Your results gene names should be like the first column and the labelled points will be like the second column.


To use metadata for coloration, we need a metadata dataframe
 that looks like this:

Samples   Condition    Color
Sample1   KO           Red
Sample2   KO           Red
Sample3   WT           Blue
Sample4   WT           Blue

contrast in this case can be input as contrast = "Condition"
metadata needs a column called Color, set it at the outset,
it will make all your plotting easier!
condition1 and condition2 should be set,
ie condition1 = "KO" and condition2 = "WT"

If we have all that, we can do this:
volcanoplot(results, metadata = metadata,
            condition1 = 'KO', condition2 = 'WT')



FerrenaAlexander/FerrenaBulkRNAseq documentation built on Oct. 16, 2022, 8:18 a.m.