do_AlluvialPlot: Generate Alluvial plots.

View source: R/do_AlluvialPlot.R

do_AlluvialPlotR Documentation

Generate Alluvial plots.

Description

This function is based on the ggalluvial package. It allows you to generate alluvial plots from a given Seurat object.

Usage

do_AlluvialPlot(
  sample,
  first_group,
  last_group,
  middle_groups = NULL,
  colors.use = NULL,
  plot.title = NULL,
  plot.subtitle = NULL,
  plot.caption = NULL,
  font.size = 14,
  font.type = "sans",
  xlab = NULL,
  ylab = "Number of cells",
  repel = FALSE,
  fill.by = last_group,
  use_labels = FALSE,
  stratum.color = "black",
  stratum.fill = "white",
  stratum.width = 1/3,
  stratum.fill.conditional = FALSE,
  use_geom_flow = FALSE,
  alluvium.color = "white",
  flow.color = "white",
  flip = FALSE,
  label.color = "black",
  curve_type = "sigmoid",
  use_viridis = FALSE,
  viridis.palette = "G",
  viridis.direction = -1,
  sequential.palette = "YlGnBu",
  sequential.direction = 1,
  plot.grid = FALSE,
  grid.color = "grey75",
  grid.type = "dashed",
  na.value = "white",
  legend.position = "right",
  legend.title = NULL,
  plot.title.face = "bold",
  plot.subtitle.face = "plain",
  plot.caption.face = "italic",
  axis.title.face = "bold",
  axis.text.face = "plain",
  legend.title.face = "bold",
  legend.text.face = "plain"
)

Arguments

sample

Seurat | A Seurat object, generated by CreateSeuratObject.

first_group

character | Categorical metadata variable. First group of nodes of the alluvial plot.

last_group

character | Categorical metadata variable. Last group of nodes of the alluvial plot.

middle_groups

character | Categorical metadata variable. Vector of groups of nodes of the alluvial plot.

colors.use

character | Named list of colors corresponding to the unique values in fill.by (which defaults to last_group).

plot.title, plot.subtitle, plot.caption

character | Title, subtitle or caption to use in the plot.

font.size

numeric | Overall font size of the plot. All plot elements will have a size relationship with this font size.

font.type

character | Base font family for the plot. One of:

  • mono: Mono spaced font.

  • serif: Serif font family.

  • sans: Default font family.

xlab, ylab

character | Titles for the X and Y axis.

repel

logical | Whether to repel the text labels.

fill.by

character | One of first_group, middle_groups (one of the values, if multiple mid_groups) or last_group. These values will be used to color the alluvium/flow.

use_labels

logical | Whether to use labels instead of text for the stratum.

stratum.color, alluvium.color, flow.color

character | Color for the border of the alluvium (and flow) and stratum.

stratum.fill

character | Color to fill the stratum.

stratum.width

logical | Width of the stratum.

stratum.fill.conditional

logical | Whether to fill the stratum with the same colors as the alluvium/flow.

use_geom_flow

logical | Whether to use geom_flow instead of geom_alluvium. Visual results might differ.

flip

logical | Whether to invert the axis of the displayed plot.

label.color

character | Color for the text labels.

curve_type

character | Type of curve used in geom_alluvium. One of:

  • linear.

  • cubic.

  • quintic.

  • sine.

  • arctangent.

  • sigmoid.

  • xspline.

use_viridis

logical | Whether to use viridis color scales.

viridis.palette

character | A capital letter from A to H or the scale name as in scale_fill_viridis.

viridis.direction

numeric | Either 1 or -1. Controls how the gradient of viridis scale is formed.

sequential.palette

character | Type of sequential color palette to use. Out of the sequential palettes defined in brewer.pal.

sequential.direction

numeric | Direction of the sequential color scale. Either 1 or -1.

plot.grid

logical | Whether to plot grid lines.

grid.color

character | Color of the grid in the plot. In heatmaps, color of the border of the cells.

grid.type

character | One of the possible linetype options:

  • blank.

  • solid.

  • dashed.

  • dotted.

  • dotdash.

  • longdash.

  • twodash.

na.value

character | Color value for NA.

legend.position

character | Position of the legend in the plot. One of:

  • top: Top of the figure.

  • bottom: Bottom of the figure.

  • left: Left of the figure.

  • right: Right of the figure.

  • none: No legend is displayed.

legend.title

character | Title for the legend.

plot.title.face, plot.subtitle.face, plot.caption.face, axis.title.face, axis.text.face, legend.title.face, legend.text.face

character | Controls the style of the font for the corresponding theme element. One of:

  • plain: For normal text.

  • italic: For text in itallic.

  • bold: For text in bold.

  • bold.italic: For text both in itallic and bold.

Value

A ggplot2 object.

Examples


  # Check Suggests.
  value <- SCpubr:::check_suggests(function_name = "do_AlluvialPlot", passive = TRUE)
  message(value)
  if (isTRUE(value)){
    # Consult the full documentation in https://enblacar.github.io/SCpubr-book/

    # Define your Seurat object.
    sample <- readRDS(system.file("extdata/seurat_dataset_example.rds", package = "SCpubr"))

    # Compute basic sankey plot.
    p <- SCpubr::do_AlluvialPlot(sample = sample,
                                 first_group = "orig.ident",
                                 last_group = "seurat_clusters")

  } else if (base::isFALSE(value)){
    message("This function can not be used without its suggested packages.")
    message("Check out which ones are needed using `SCpubr::state_dependencies()`.")
  }


enblacar/SCpubr documentation built on Aug. 25, 2024, 9:45 p.m.