markerExpressionPerCluster: Generate box-and-whisker plots illustrating marker expression...

Description Usage Arguments Details Value Author(s) Examples

View source: R/markerExpressionPerCluster.R

Description

Generate box-and-whisker plots illustrating marker expression per k-NN identified cluster. By default, 5 randomly-selected clusters are selected, and the expression profiles of 10 randomly-selected markers are plot across these.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
markerExpressionPerCluster(
  indata,
  assay = "scaled",
  clusters = sample(unique(metadata(indata)[["Cluster"]]), 5),
  clusterAssign = metadata(indata)[["Cluster"]],
  markers = sample(rownames(indata), 10),
  ncol = 5,
  nrow = 2,
  legendPosition = "none",
  legendLabSize = 12,
  legendKeyHeight = 2.5,
  xlim = NULL,
  ylim = NULL,
  yfixed = FALSE,
  xlab = "Marker",
  xlabAngle = 90,
  xlabhjust = 0.5,
  xlabvjust = 0.5,
  ylab = "Expression",
  ylabAngle = 0,
  ylabhjust = 0.5,
  ylabvjust = 0.5,
  axisLabSize = 16,
  stripLabSize = 16,
  title = "Marker expression per cluster",
  subtitle = "",
  caption = "",
  titleLabSize = 16,
  subtitleLabSize = 12,
  captionLabSize = 12,
  borderWidth = 0.8,
  borderColour = "black",
  verbose = TRUE
)

Arguments

indata

A data-frame or matrix, or SingleCellExperiment object. If a data-frame or matrix, this should relate to expression data (cells as columns; genes as rows). If a SingleCellExperiment object, data will be extracted from an assay component named by assay.

assay

Name of the assay slot in indata from which data will be taken, assuming indata is a SingleCellExperiment object.

clusters

Vector containing clusters to plot.

clusterAssign

A vector of cell-to-cluster assignments. This can be from any source but must align with your cells / variables. There is no check to ensure this when indata is not a SingleCellExperiment object.

markers

Vector containing marker names to plot.

ncol

Number of columns for faceting.

nrow

Number of rows for faceting.

legendPosition

Position of legend ('top', 'bottom', 'left', 'right', 'none').

legendLabSize

Size of plot legend text.

legendKeyHeight

Height of the legend key.

xlim

Limits of the x-axis.

ylim

Limits of the y-axis.

yfixed

Logical, specifying whether or not to fix the y-axis scales across all clusters when faceting.

xlab

Label for x-axis.

xlabAngle

Rotation angle of x-axis labels.

xlabhjust

Horizontal adjustment of x-axis labels.

xlabvjust

Vertical adjustment of x-axis labels.

ylab

Label for y-axis.

ylabAngle

Rotation angle of y-axis labels.

ylabhjust

Horizontal adjustment of y-axis labels.

ylabvjust

Vertical adjustment of y-axis labels.

axisLabSize

Size of x- and y-axis labels.

stripLabSize

Size of the strip labels.

title

Plot title.

subtitle

Plot subtitle.

caption

Plot caption.

titleLabSize

Size of plot title.

subtitleLabSize

Size of plot subtitle.

captionLabSize

Size of plot caption.

borderWidth

Width of the border on the x and y axes.

borderColour

Colour of the border on the x and y axes.

verbose

Boolean (TRUE / FALSE) to print messages to console or not.

Details

Generate box-and-whisker plots illustrating marker expression per k-NN identified cluster. By default, 5 randomly-selected clusters are selected, and the expression profiles of 10 randomly-selected markers are plot across these.

Value

A ggplot2 object.

Author(s)

Kevin Blighe <kevin@clinicalbioinformatics.co.uk>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# create random data that follows a negative binomial
mat <- jitter(matrix(
  MASS::rnegbin(rexp(5000, rate=.1), theta = 4.5),
  ncol = 20))
colnames(mat) <- paste0('CD', 1:ncol(mat))
rownames(mat) <- paste0('cell', 1:nrow(mat))

clus <- clusKNN(mat)
markerExpressionPerCluster(t(mat), clusters = c(0, 1),
  clusterAssign = clus)

kevinblighe/scDataviz documentation built on Sept. 28, 2021, 12:04 p.m.