Learn R Programming

diceplot (version 0.1.7)

domino_plot: Domino Plot Visualization

Description

This function generates a plot to visualize gene expression levels for a given list of genes. The size of the dots can be customized, and the plot can be saved to an output file if specified.

Usage

domino_plot(
  data,
  gene_list,
  x = "gene",
  y = "Celltype",
  contrast = "Contrast",
  var_id = "var",
  log_fc = "avg_log2FC",
  p_val = "p_val_adj",
  min_dot_size = 1,
  max_dot_size = 5,
  spacing_factor = 3,
  logfc_colors = c(low = "blue", mid = "white", high = "red"),
  color_scale_name = "Log2 Fold Change",
  size_scale_name = "-log10(adj. p-value)",
  axis_text_size = 8,
  x_axis_text_size = NULL,
  y_axis_text_size = NULL,
  legend_text_size = 8,
  cluster_method = "complete",
  cluster_y_axis = TRUE,
  cluster_var_id = TRUE,
  base_width = 5,
  base_height = 4,
  show_legend = TRUE,
  legend_width = 0.25,
  legend_height = 0.5,
  custom_legend = TRUE,
  logfc_limits = NULL,
  aspect_ratio = NULL,
  switch_axis = FALSE,
  reverse_y_ordering = FALSE,
  show_var_positions = FALSE,
  output_file = NULL,
  feature_col = NULL,
  celltype_col = NULL,
  contrast_col = NULL,
  logfc_col = NULL,
  pval_col = NULL
)

Value

A list containing the domino plot and optionally the variable positions plot.

Arguments

data

A data frame containing gene expression data.

gene_list

A character vector of gene names to include in the plot.

x

A string representing the column name in data for the feature variable (e.g., genes). Default is "gene".

y

A string representing the column name in data for the cell type variable. Default is "Celltype".

contrast

A string representing the column name in data for the contrast variable. Default is "Contrast".

var_id

A string representing the column name in data for the variable identifier. Default is "var".

log_fc

A string representing the column name in data for the log fold change values. Default is "avg_log2FC".

p_val

A string representing the column name in data for the adjusted p-values. Default is "p_val_adj".

min_dot_size

A numeric value indicating the minimum dot size in the plot. Default is 1.

max_dot_size

A numeric value indicating the maximum dot size in the plot. Default is 5.

spacing_factor

A numeric value indicating the spacing between gene pairs. Default is 3.

logfc_colors

A named vector specifying the colors for the low, mid, and high values in the color scale. Default is c(low = "blue", mid = "white", high = "red").

color_scale_name

A string specifying the name of the color scale in the legend. Default is "Log2 Fold Change".

size_scale_name

A string specifying the name of the size scale in the legend. Default is "-log10(adj. p-value)".

axis_text_size

A numeric value specifying the size of the axis text. Default is 8.

x_axis_text_size

A numeric value specifying the size of the x-axis text. If NULL, uses axis_text_size. Default is NULL.

y_axis_text_size

A numeric value specifying the size of the y-axis text. If NULL, uses axis_text_size. Default is NULL.

legend_text_size

A numeric value specifying the size of the legend text. Default is 8.

cluster_method

The clustering method to use. Default is "complete".

cluster_y_axis

A logical value indicating whether to cluster the y-axis (cell types). Default is TRUE.

cluster_var_id

A logical value indicating whether to cluster the var_id. Default is TRUE.

base_width

A numeric value specifying the base width for saving the plot. Default is 5.

base_height

A numeric value specifying the base height for saving the plot. Default is 4.

show_legend

A logical value indicating whether to show the legend. Default is TRUE.

legend_width

A numeric value specifying the relative width of the legend. Default is 0.25.

legend_height

A numeric value specifying the relative height of the legend. Default is 0.5.

custom_legend

A logical value indicating whether to use a custom legend. Default is TRUE.

logfc_limits

A numeric vector of length 2 specifying the limits for the log fold change color scale. If NULL (default), no limits are applied.

aspect_ratio

A numeric value specifying the aspect ratio of the plot. If NULL, it's calculated automatically. Default is NULL.

switch_axis

A logical value indicating whether to switch the x and y axes. Default is FALSE.

reverse_y_ordering

A logical value indicating whether to reverse the y-axis ordering after clustering. Default is FALSE.

show_var_positions

A logical value indicating whether to show the intermediate variable positions plot. Default is FALSE. When output_file is specified with a PDF extension, both plots will be saved to a multi-page PDF if this is TRUE. A warning will be shown if show_var_positions is TRUE but the output file is not a PDF.

output_file

An optional string specifying the path to save the plot. If NULL, the plot is not saved. Default is NULL.

feature_col

Deprecated. Use x instead.

celltype_col

Deprecated. Use y instead.

contrast_col

Deprecated. Use contrast instead.

logfc_col

Deprecated. Use log_fc instead.

pval_col

Deprecated. Use p_val instead.