do_RidgePlot: Create ridge plots.

View source: R/do_RidgePlot.R

do_RidgePlotR Documentation

Create ridge plots.

Description

This function computes ridge plots based on the ggridges package.

Usage

do_RidgePlot(
  sample,
  feature,
  group.by = NULL,
  split.by = NULL,
  assay = "SCT",
  slot = "data",
  continuous_scale = FALSE,
  legend.title = NULL,
  legend.ncol = NULL,
  legend.nrow = NULL,
  legend.byrow = FALSE,
  legend.position = NULL,
  legend.width = 1,
  legend.length = 20,
  legend.framewidth = 0.5,
  legend.tickwidth = 0.5,
  legend.framecolor = "grey50",
  legend.tickcolor = "white",
  legend.type = "colorbar",
  colors.use = NULL,
  font.size = 14,
  font.type = "sans",
  axis.text.x.angle = 45,
  plot.title = NULL,
  plot.subtitle = NULL,
  plot.caption = NULL,
  xlab = NULL,
  ylab = NULL,
  compute_quantiles = FALSE,
  compute_custom_quantiles = FALSE,
  quantiles = c(0.25, 0.5, 0.75),
  compute_distribution_tails = FALSE,
  prob_tails = 0.025,
  color_by_probabilities = FALSE,
  use_viridis = TRUE,
  viridis.palette = "G",
  viridis.direction = 1,
  sequential.palette = "YlGnBu",
  sequential.direction = 1,
  plot.grid = TRUE,
  grid.color = "grey75",
  grid.type = "dashed",
  flip = FALSE,
  number.breaks = 5,
  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.

feature

character | Feature to represent.

group.by

character | Metadata variable to group the output by. Has to be a character of factor column.

split.by

character | Secondary metadata variable to further group (split) the output by. Has to be a character of factor column.

assay

character | Assay to use. Defaults to the current assay.

slot

character | Data slot to use. Only one of: counts, data, scale.data. Defaults to "data".

continuous_scale

logical | Whether to color the ridges depending on a categorical or continuous scale.

legend.title

character | Title for the legend.

legend.ncol

numeric | Number of columns in the legend.

legend.nrow

numeric | Number of rows in the legend.

legend.byrow

logical | Whether the legend is filled by row or not.

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.length, legend.width

numeric | Length and width of the legend. Will adjust automatically depending on legend side.

legend.framewidth, legend.tickwidth

numeric | Width of the lines of the box in the legend.

legend.framecolor

character | Color of the lines of the box in the legend.

legend.tickcolor

character | Color of the ticks of the box in the legend.

legend.type

character | Type of legend to display. One of:

  • normal: Default legend displayed by ggplot2.

  • colorbar: Redefined colorbar legend, using guide_colorbar.

colors.use

character | Named vector of colors to use. Has to match the unique values of group.by or color.by (if used) when scale_type is set to categorical.

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.

axis.text.x.angle

numeric | Degree to rotate the X labels. One of: 0, 45, 90.

plot.title, plot.subtitle, plot.caption

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

xlab, ylab

character | Titles for the X and Y axis.

compute_quantiles

logical | Whether to compute quantiles of the distribution and color the ridge plots by them.

compute_custom_quantiles

logical | Whether to compute custom quantiles.

quantiles

numeric | Numeric vector of quantiles.

compute_distribution_tails

logical | Whether to compute distribution tails and color them.

prob_tails

numeric | The accumulated probability that the tails should contain.

color_by_probabilities

logical | Whether to color the ridges depending on the probability.

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.

flip

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

number.breaks

numeric | Controls the number of breaks in continuous color scales of ggplot2-based plots.

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_RidgePlot", passive = TRUE)

  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 the most basic ridge plot.
    p <- SCpubr::do_RidgePlot(sample = sample,
                              feature = "nFeature_RNA")
    p

    # Use continuous color scale.
    p <- SCpubr::do_RidgePlot(sample = sample,
                              feature = "nFeature_RNA",
                              continuous_scale = TRUE,
                              viridis.direction = 1)
    p

    # Draw quantiles of the distribution.
    p <- SCpubr::do_RidgePlot(sample = sample,
                              feature = "nFeature_RNA",
                              continuous_scale = TRUE,
                              compute_quantiles = TRUE,
                              compute_custom_quantiles = TRUE)
    p

    # Draw probability tails.
    p <- SCpubr::do_RidgePlot(sample = sample,
                              feature = "nFeature_RNA",
                              continuous_scale = TRUE,
                              compute_quantiles = TRUE,
                              compute_distribution_tails = TRUE)
    p

    # Draw probability tails.
    p <- SCpubr::do_RidgePlot(sample = sample,
                              feature = "nFeature_RNA",
                              continuous_scale = TRUE,
                              compute_quantiles = TRUE,
                              color_by_probabilities = TRUE)
    p
  } 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()`.")
  }


SCpubr documentation built on Oct. 11, 2023, 5:15 p.m.