Skip to contents

This function generates a barplot of the proportion of cells from a Seurat object.

Usage

Barplot_Cell_Proportion(
  seurat_object,
  group.by = NULL,
  split.by = NULL,
  colors = NULL,
  order.proportion = NULL,
  order.group = NULL,
  order.split = NULL,
  order.colors = TRUE,
  alpha = 1,
  show.cellsum.label = TRUE,
  cellsum.label.size = 3,
  axis.text.size = 9,
  x.axis.angle = 60,
  x.axis.hjust = 1,
  y.axis.title.size = 11,
  legend.text.size = 9,
  legend.side = "bottom",
  show.legend = TRUE,
  split.plot.title.size = 24,
  percent = TRUE,
  nrow = 1,
  unique.group.plot = TRUE,
  unique.split.plot = FALSE
)

Arguments

seurat_object

A Seurat object.

group.by

Character. The name of an identity in the meta.data slot to group the active.ident identity by into a stacked barplot.

split.by

Character. The name of an identity in the meta.data slot to split the active.ident identity by into separate ggplot objects.

colors

Character. A vector of colors to use for the active.ident identity, of same length as the number of identities in the active.ident identity. If NULL, uses Seurat's default colors.

order.proportion

Character or Numeric. A vector specifying either 'reverse' or the levels (as character or as numeric values corresponding to the indexes) of the active.ident identity to order the cells.

order.group

Character. A vector specifying either 'reverse' or the levels of the group.by identity to order the cells. Ignored if group.by = NULL.

order.split

Character. A vector specifying either 'reverse' or the levels of the split.by identity to order the cells. Ignored if split.by = NULL.

order.colors

Logical. If TRUE, the colors for the active.ident identity, the group.by identity and the split.by identity will automatically be ordered according to order.idents, order.group and order.split. Ignored if order.idents, order.group and order.split are NULL.

alpha

Numeric. The transparency of the bars colors. A value between 0 and 1.

show.cellsum.label

Logical. If TRUE, the cell sum of each identity will be shown at the top of each bar.

cellsum.label.size

Numeric. The font size of the cell sum label. Ignored if show.cellsum.label = FALSE.

axis.text.size

Numeric. The font size of the identities names and cell percent or numbers.

x.axis.angle

Numeric. The angle of rotation of the identities names.

x.axis.hjust

Numeric. The horizontal justification of the identities names.

y.axis.title.size

Numeric. The font size of the y axis title.

legend.text.size

Numeric. The font size of the legend text. Ignored if show.legend = FALSE.

legend.side

Character. The side where the legend will be displayed, either 'left', 'right', 'top' or 'bottom'. Ignored if show.legend = FALSE.

show.legend

Logical. If TRUE, shows the legend.

split.plot.title.size

Numeric. The font size of the split plots titles. Ignored if split.by = NULL.

percent

Logical. If TRUE, the proportion of cells will be shown as a percentage of total cells for each identity. Ignored if group.by = NULL.

nrow

Numeric. The number of rows in the patchwork. Ignored if group.by = NULL and split.by = NULL.

unique.group.plot

Logical. If TRUE, the stacked barplots will be gathered in a single ggplot object.

unique.split.plot

Logical. If TRUE, the ggplot objects will be gathered in a single patchwork.

Value

A ggplot object, a list of ggplot objects, a patchwork of ggplot objects or a list of patchworks of ggplot objects.

Examples

# Prepare data
pbmc3k <- Right_Data("pbmc3k")

# Example 1: default parameters
Barplot_Cell_Proportion(pbmc3k)