tof_plot_clusters_volcano: Create a volcano plot from differential expression analysis...

View source: R/visualization.R

tof_plot_clusters_volcanoR Documentation

Create a volcano plot from differential expression analysis results

Description

This function makes a volcano plot using the results of a differential expression analysis (DEA) produced by one of the 'tof_dea_*' verbs. Each point in the volcano plot represents a single cluster-marker pair, colored by significance level and the direction of the marker expression difference.

Usage

tof_plot_clusters_volcano(
  dea_result,
  num_top_pairs = 10L,
  alpha = 0.05,
  point_size = 2,
  label_size = 3,
  nudge_x = 0,
  nudge_y = 0.25,
  increase_color = "#207394",
  decrease_color = "#cd5241",
  insignificant_color = "#cdcdcd",
  use_ggrepel = FALSE,
  theme = ggplot2::theme_bw()
)

Arguments

dea_result

A tibble containing the differential expression analysis (DEA) results produced by one of the members of the 'tof_dea_*' function family.

num_top_pairs

An integer representing the number of most significant cluster-marker pairs that should be labeled in the volcano plot.

alpha

A numeric value between 0 and 1 representing the significance level below which a p-value should be considered statistically significant. Defaults to 0.05.

point_size

A numeric value specifying the size of the points in the volcano plot.

label_size

A numeric value specifying the size of the text labeling cluster-marker pairs.

nudge_x

A numeric value specifying how far cluster-marker pair labels should be adjusted to the left (if 'nudge_x' is negative) or to the right (if 'nudge_x' is positive) to avoid overlap with the plotted points. Passed to geom_text, and ignored if 'use_ggrepel' = TRUE. Defaults to 0.

nudge_y

A numeric value specifying how far cluster-marker pair labels should be adjusted downwards (if 'nudge_y' is negative) or upwards (if 'nudge_y' is positive) to avoid overlap with the plotted points. Passed to geom_text, and ignored if 'use_ggrepel' = TRUE. Defaults to 0.25.

increase_color

A hex code specifying which fill color should be used for points corresponding to cluster-marker pairs where significant increases were detected.

decrease_color

A hex code specifying which fill color should be used for points corresponding to cluster-marker pairs where significant decreases were detected.

insignificant_color

A hex code specifying which fill color should be used for points corresponding to cluster-marker pairs where no significant differences were detected.

use_ggrepel

A boolean value indicting if geom_text_repel should be used to plot labels for cluster-marker pairs. Defaults to FALSE. If TRUE, the ggrepel package must be installed.

theme

A ggplot2 theme to apply to the volcano plot. Defaults to theme_bw

Value

A ggplot object.

Examples


# create a mock differential expression analysis result
sim_dea_result <-
    dplyr::tibble(
        cluster_id = rep(letters, 2),
        marker = rep(c("cd45", "cd34"), times = length(letters)),
        p_adj = runif(n = 2 * length(letters), min = 0, max = 0.5),
        mean_fc = runif(n = 2 * length(letters), min = 0.01, max = 10),
        significant = dplyr::if_else(p_adj < 0.05, "*", "")
    )

attr(sim_dea_result, which = "dea_method") <- "t_unpaired"

# create the volcano plot
volcano <- tof_plot_clusters_volcano(dea_result = sim_dea_result)


keyes-timothy/tidytof documentation built on May 7, 2024, 12:33 p.m.