volcano_plot: Volcano Plot Creation

View source: R/volcono_plot2.R

volcano_plotR Documentation

Volcano Plot Creation

Description

Creates a volcano plot for visualizing differential expression results, highlighting significant changes in expression levels.

Usage

volcano_plot(
  object,
  fc_column_name = "fc",
  log2_fc = TRUE,
  p_value_column_name = "p_value_adjust",
  labs_x = "log2(Fold change)",
  labs_y = "-log(p-adjust, 10)",
  fc_up_cutoff = 2,
  fc_down_cutoff = 0.5,
  p_value_cutoff = 0.05,
  line_color = "red",
  up_color = "#EE0000FF",
  down_color = "#3B4992FF",
  no_color = "#808180FF",
  point_size = 2,
  point_alpha = 1,
  point_size_scale = "log10_p",
  line_type = 1,
  add_text = FALSE,
  text_for = c("marker", "UP", "DOWM"),
  text_from = "variable_id"
)

## S3 method for class 'mass_dataset'
volcano_plot(
  object,
  fc_column_name = "fc",
  log2_fc = TRUE,
  p_value_column_name = "p_value_adjust",
  labs_x = "log2(Fold change)",
  labs_y = "-log(p-adjust, 10)",
  fc_up_cutoff = 2,
  fc_down_cutoff = 0.5,
  p_value_cutoff = 0.05,
  line_color = "red",
  up_color = "#EE0000FF",
  down_color = "#3B4992FF",
  no_color = "#808180FF",
  point_size = 2,
  point_alpha = 1,
  point_size_scale = "log10_p",
  line_type = 1,
  add_text = FALSE,
  text_for = c("marker", "UP", "DOWM"),
  text_from = "variable_id"
)

## S3 method for class 'data.frame'
volcano_plot(
  object,
  fc_column_name = "fc",
  log2_fc = TRUE,
  p_value_column_name = "p_value_adjust",
  labs_x = "log2(Fold change)",
  labs_y = "-log(p-adjust, 10)",
  fc_up_cutoff = 2,
  fc_down_cutoff = 0.5,
  p_value_cutoff = 0.05,
  line_color = "red",
  up_color = "#EE0000FF",
  down_color = "#3B4992FF",
  no_color = "#808180FF",
  point_size = 2,
  point_alpha = 1,
  point_size_scale = "log10_p",
  line_type = 1,
  add_text = FALSE,
  text_for = c("marker", "UP", "DOWM"),
  text_from = "variable_id"
)

Arguments

object

An object containing the data to be plotted. Can be a 'data.frame', 'mass_dataset' object, or other types for which methods are defined.

fc_column_name

The name of the column containing fold change values. Defaults to '"fc"'.

log2_fc

Logical, indicating if fold change values should be log2 transformed. Defaults to 'TRUE'.

p_value_column_name

The name of the column containing p-value adjustments. Defaults to '"p_value_adjust"'.

labs_x

The label for the x-axis. Defaults to '"log2(Fold change)"'.

labs_y

The label for the y-axis. Defaults to '"-log(p-adjust, 10)"'.

fc_up_cutoff

The fold change cutoff for considering an expression level significantly up-regulated. Defaults to '2'.

fc_down_cutoff

The fold change cutoff for considering an expression level significantly down-regulated. Defaults to '0.5'.

p_value_cutoff

The p-value cutoff for significance. Defaults to '0.05'.

line_color

The color of the lines marking cutoffs. Defaults to '"red"'.

up_color

The color used for points representing up-regulated variables. Defaults to '"#EE0000FF"'.

down_color

The color used for points representing down-regulated variables. Defaults to '"#3B4992FF"'.

no_color

The color used for points not meeting significance criteria. Defaults to '"#808180FF"'.

point_size

The base size of points in the plot. Defaults to '2'.

point_alpha

The transparency level of points in the plot. Defaults to '1'.

point_size_scale

A character string indicating if and how the size of points should scale, typically based on significance. Optional.

line_type

The type of line to use for cutoff markers. Defaults to '1'.

add_text

Logical, indicating if labels should be added to significant points. Defaults to 'FALSE'.

text_for

A character vector indicating which points to label based on their 'marker' status. Possible values are '"marker"', '"UP"', '"DOWN"', or a combination thereof. Defaults to 'c("marker", "UP", "DOWN")'.

text_from

The name of the column containing labels for text annotations. Required if 'add_text' is 'TRUE'.

Value

A ggplot object representing the volcano plot.

Author(s)

Xiaotao Shen shenxt1990@outlook.com

Examples

library(massdataset)
library(magrittr)
library(dplyr)

data("liver_aging_pos")
liver_aging_pos

w_78 =
  liver_aging_pos %>%
  activate_mass_dataset(what = "sample_info") %>%
  dplyr::filter(group == "78W") %>%
  dplyr::pull(sample_id)

w_24 =
  liver_aging_pos %>%
  activate_mass_dataset(what = "sample_info") %>%
  dplyr::filter(group == "24W") %>%
  dplyr::pull(sample_id)

control_sample_id = w_24
case_sample_id = w_78

liver_aging_pos =
  mutate_fc(
    object = liver_aging_pos,
    control_sample_id = control_sample_id,
    case_sample_id = case_sample_id,
    mean_median = "mean"
  )

liver_aging_pos =
  mutate_p_value(
    object = liver_aging_pos,
    control_sample_id = control_sample_id,
    case_sample_id = case_sample_id,
    method = "t.test",
    p_adjust_methods = "BH"
  )

object = liver_aging_pos
volcano_plot(
  object = object,
  fc_column_name = "fc",
  p_value_column_name = "p_value_adjust",
  labs_x = "log2(Fold change)",
  labs_y = "-log(p-adjust, 10)",
  fc_up_cutoff = 2,
  fc_down_cutoff = 0.5,
  p_value_cutoff = 0.05,
  add_text = TRUE
)
volcano_plot(
  object = object,
  fc_column_name = "fc",
  p_value_column_name = "p_value",
  labs_x = "log2(Fold change)",
  labs_y = "-log(p-value, 10)",
  fc_up_cutoff = 2,
  fc_down_cutoff = 0.5,
  p_value_cutoff = 0.05,
  add_text = FALSE,
  point_alpha = 0.5
)

volcano_plot(
  object = object,
  fc_column_name = "fc",
  p_value_column_name = "p_value",
  labs_x = "log2(Fold change)",
  labs_y = "-log(p-value, 10)",
  fc_up_cutoff = 2,
  fc_down_cutoff = 0.5,
  p_value_cutoff = 0.05,
  add_text = FALSE,
  point_alpha = 0.5,
  point_size_scale = "p_value"
) +
  scale_size_continuous(range = c(0.5, 3))

tidymass/massstat documentation built on March 12, 2024, 6:24 a.m.