do_DotPlot: This function is a wrapper for DotPlot. It provides most of...

View source: R/do_DotPlot.R

do_DotPlotR Documentation

This function is a wrapper for DotPlot. It provides most of its functionalities while adding extra. You can

Description

This function is a wrapper for DotPlot. It provides most of its functionalities while adding extra. You can

Usage

do_DotPlot(
  sample,
  features,
  assay = NULL,
  group.by = NULL,
  scale = FALSE,
  legend.title = NULL,
  legend.type = "colorbar",
  legend.position = "bottom",
  legend.framewidth = 0.5,
  legend.tickwidth = 0.5,
  legend.length = 20,
  legend.width = 1,
  legend.framecolor = "grey50",
  legend.tickcolor = "white",
  colors.use = NULL,
  dot.scale = 6,
  plot.title = NULL,
  plot.subtitle = NULL,
  plot.caption = NULL,
  xlab = NULL,
  ylab = NULL,
  font.size = 14,
  font.type = "sans",
  cluster = FALSE,
  flip = FALSE,
  axis.text.x.angle = 45,
  scale.by = "size",
  use_viridis = FALSE,
  viridis.palette = "G",
  viridis.direction = -1,
  sequential.palette = "YlGnBu",
  sequential.direction = 1,
  na.value = "grey75",
  dot_border = TRUE,
  plot.grid = TRUE,
  grid.color = "grey75",
  grid.type = "dashed",
  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.

features

character | Features to represent.

assay

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

group.by

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

scale

logical | Whether the data should be scaled or not. Non-scaled data allows for comparison across genes. Scaled data allows for an easier comparison along the same gene.

legend.title

character | Title for 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.

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.framewidth, legend.tickwidth

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

legend.length, legend.width

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

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.

colors.use

named_vector | Named vector of valid color representations (either name of HEX codes) with as many named colors as unique values of group.by. If group.by is not provided, defaults to the unique values of Idents. If not provided, a color scale will be set by default.

dot.scale

numeric | Scale the size of the dots.

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.

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.

cluster

logical | Whether to cluster the identities based on the expression of the features.

flip

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

axis.text.x.angle

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

scale.by

character | How to scale the size of the dots. One of:

  • radius: use radius aesthetic.

  • size: use size aesthetic.

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.

na.value

character | Color value for NA.

dot_border

logical | Whether to plot a border around dots.

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.

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 containing a Dot Plot.

Examples


  # Check Suggests.
  value <- SCpubr:::check_suggests(function_name = "do_DotPlot", passive = TRUE)

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

    # Basic Dot plot.
    p <- SCpubr::do_DotPlot(sample = sample,
                            features = "EPC1")

    # Querying multiple features.
    genes <- rownames(sample)[1:14]
    p <- SCpubr::do_DotPlot(sample = sample,
                            features = genes)

    # Inverting the axes.
    p <- SCpubr::do_DotPlot(sample = sample,
                            features = genes,
                            cluster = TRUE,
                            plot.title = "Clustered",
                            flip = TRUE)

    # Modifying default colors.
    # Two colors to generate a gradient.
    p <- SCpubr::do_DotPlot(sample = sample,
                            features = genes,
                            colors.use = c("#001219", "#e9d8a6"))

    # Querying multiple features as a named list - splitting by each item in list.
    # Genes have to be unique.
    genes <- list("Naive CD4+ T" = rownames(sample)[1:2],
                  "EPC1+ Mono" = rownames(sample)[3:4],
                  "Memory CD4+" = rownames(sample)[5],
                  "B" = rownames(sample)[6],
                  "CD8+ T" = rownames(sample)[7],
                  "FCGR3A+ Mono" = rownames(sample)[8:9],
                  "NK" = rownames(sample)[10:11],
                  "DC" = rownames(sample)[12:13],
                  "Platelet" = rownames(sample)[14])

    p <- SCpubr::do_DotPlot(sample = sample,
                            features = genes)

    # Clustering the identities.
    p <- SCpubr::do_DotPlot(sample = sample,
                            features = genes,
                            cluster = TRUE,
                            plot.title = "Clustered")
  } 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.