plot_overlay: superimpose genesets onto plots

View source: R/plot_overlay.R

plot_overlayR Documentation

superimpose genesets onto plots

Description

Takes a ggplot2 object and superimoses genes from a reference data.frame. This data.frame can be constructed manually or generated with a variety of functions, e.g. get_inweb_list, get_irefindex_list or get_tissue_list.

The function uses the mapping and plot environment from a previous ggplot to add an overlay with a matching 'reference' data.frame. This yields a new plot with items that intersect the the original ggplot data and the reference data. Can be applied iteratively. The user can input certain columns in the reference to gain more control over the plotting parameters of individual points. See notes for additional details.

Usage

plot_overlay(
  p,
  reference,
  match = "gene",
  size_gg = 3.5,
  stroke = 0.75,
  sig_text = NULL,
  insig_text = NULL,
  label = NULL,
  label_size = NULL,
  label_color = "black",
  col_significant = NULL,
  col_other = NULL,
  label_box_padding = 0.3,
  label_point_padding = 0.5,
  label_arrowhead_size = 0.01,
  label_max_overlaps = 10,
  legend_nchar_max = NULL,
  nchar_max_collapse = "<br>"
)

Arguments

p

A ggplot object passed down from plot_volcano_basic or plot_scatter_basic.

reference

a named list of data.frames.

match

string. By what string should the ggplot and overlay be merged? Default is 'gene'.

size_gg

numeric. Size of ggplot points.

stroke

numeric. The width of the outline/borders.

sig_text

string. Text for significant interactors to be displayed in legend.

insig_text

string. Text for non-significant interactors to be displayed in legend.

label

boolean. This will overwrite the label column in the reference data.frame.

label_size

numeric. Size of label. This will overwrite the label.size column in the reference data.frame.

label_color

string. The color of the label. Default is black.

col_significant

string. Color of superimposed genes that are significant.

col_other

string. Color of superimposed genes that are non-significant.

label_box_padding

numeric. Amount of padding around bounding box. See ?ggrepel::geom_text_repel.

label_point_padding

numeric. Amount of padding around label. See ?ggrepel::geom_text_repel.

label_arrowhead_size

numeric. The size of the arrowhead. 0 means no arrowhead.

label_max_overlaps

integer. Exclude text labels that overlap too many things. See ?ggrepel::geom_text_repel.

legend_nchar_max

integer. Maximum amount of allowed characters in the legend.

nchar_max_collapse

string. What character should be used for line break? Default is HTML line break "<br>".

Note

The following data.frame headers for a reference are accepted:

  • "gene" A string tht indicates the gene name.

  • "label" A boolen that indicates whether the label should be plotted.

  • "label.size"A numeric that indicates the size of the label items.

See ?validate_reference for additional details.

Examples

## Not run: 
df <- example_data %>%
  calc_mod_ttest() %>%
  id_significant_proteins()

# overlay simple  a bait
df %>% 
  plot_volcano_basic() %>%
  plot_overlay(as.bait('BCL2')) 

# make a custom overlay with custom colors
myoverlay = data.frame(gene = c('FUS', 'RBMX'),
                       col_significant = c('cyan', 'blue'),
                       col_other = c('grey', 'grey'), 
                       dataset = c('group 1', 'group 2'))

# plot overlay
df %>% 
  plot_volcano_basic() %>%
  plot_overlay(list(overlay = myoverlay)) 

# plot multiple overlays
df %>% 
  plot_volcano_basic() %>%
  plot_overlay(list(overlay = myoverlay)) %>%
  plot_overlay(as.bait('BCL2')) 

## End(Not run)

lagelab/Genoppi documentation built on Oct. 13, 2022, 2:36 p.m.