plotBox: Create a boxplot of expression values

View source: R/func_sc.R

plotBoxR Documentation

Create a boxplot of expression values

Description

This function produces a boxplot to show the gene expression intensity for a grouping of cells.

Usage

plotBox(
  sce,
  features,
  columns = NULL,
  group_by = NULL,
  color_by = "Detected",
  box_colors = NULL,
  detection_limit = 0,
  max_detected = NULL,
  exprs_by = "logcounts",
  facet_ncol = NULL,
  guides_barheight = NULL,
  x.text_size = NULL,
  x.text_angle = 0,
  theme_size = 18
)

Arguments

sce

A SingleCellExperiment object.

features

A character (or factor) vector of row names, a logical vector, or integer vector of indices specifying rows of sce to visualize.

columns

A character vector of col names, a logical vector, or integer vector of indices specifying the columns (i.e. subset of cells) of sce to visualize. By default, all columns (cells) are used.

group_by

A character vector of length no more than 2 indicating the field(s) of colData(sce) containing the grouping factor, e.g., cell types or clusters, to group cells by.

color_by

A character string of either "Group" or "Detected" indicating how to colour the boxplot. For the option of "Detected, the boxplot will be colour according to the proportion of cells with detectable expression values. "Default is "Detected".

box_colors

A character vector of colour codes indicating the colours of the cell groups, or a palette function that creates a vector of colours along a colour map. Default is NULL.

detection_limit

A numeric scalar indicating the value above which observations are deemed to be expressed. Default is 0.

max_detected

A numeric value indicating the cap on the proportion of detected expression values. Default is Default is NULL.

exprs_by

A string or integer scalar specifying which assay from sce to obtain expression values from, for use in boxplot aesthetics. Use assayNames(sce) to find all availavle assays in sce. Default is "logcounts".

facet_ncol

A numeric scalar indicating the number of columns to show in the facet wrap. Default is NULL.

guides_barheight

A numeric or a grid::unit() object specifying the width and height of the colourbar. Default is NULL.

x.text_size

A numeric scalar indicating the size of x axis labels. Default is NULL.

x.text_angle

A numeric scalar indicating the angle of x axis labels. Possible choices are 0, 45, 90. Default is 0.

theme_size

A numeric scalar indicating the base font size. Default is 18.

Details

The function creates a boxplot showing the expression of selected features in groups of cells.

Value

A ggplot object

Author(s)

I-Hsuan Lin

Examples

# Load demo dataset
data(sce)

# All cells in 1 group
plotBox(sce, features = rownames(sce)[10:13])

# Group cells by "label", colour by cell groups, and change theme base size
plotBox(sce, features = rownames(sce)[10:13], group_by = "label",
  color_by = "Group", theme_size = 14)

# Show cells of labels A and B only and change colour palette
keep <- sce$label %in% c("A","B")
plotBox(sce, features = rownames(sce)[10:13], group_by = "label",
  box_colors = rainbow(50), columns = keep)

# Group cells by "label" and "CellType", showing 2 features per row
plotBox(sce, features = rownames(sce)[10:15],
  group_by = c("label","CellType"), box_colors = rainbow(50),
  facet_ncol = 2, x.text_angle = 90, x.text_size = 14)

ycl6/scRUtils documentation built on Feb. 18, 2025, 6:14 a.m.