markerExpression {scDataviz} | R Documentation

## Highlight the individual marker expression profile across a 2-dimensional reduction / embedding, typically contained within a `SingleCellExperiment` object. By default, this function plots the expression profile of 6 randomly-selected markers from your data.

### Description

Highlight the individual marker expression profile across a 2-dimensional reduction / embedding, typically contained within a `SingleCellExperiment` object. By default, this function plots the expression profile of 6 randomly-selected markers from your data.

### Usage

    markerExpression(
      indata,
      layout = NULL,
      assay = "scaled",
      reducedDim = "UMAP",
      dimColnames = c("UMAP1", "UMAP2"),
      markers = sample(rownames(indata), 6),
      ncol = 3,
      nrow = 2,
      col = c("darkblue", "yellow"),
      colMidpoint = 0,
      alpha = c(0, 1),
      pointSize = 0.5,
      legendPosition = "right",
      legendLabSize = 12,
      legendKeyHeight = 2.5,
      xlim = NULL,
      ylim = NULL,
      celllab = NULL,
      labSize = 3,
      labhjust = 1.5,
      labvjust = 0,
      drawConnectors = TRUE,
      widthConnectors = 0.5,
      colConnectors = "black",
      xlab = dimColnames[1],
      xlabAngle = 0,
      xlabhjust = 0.5,
      xlabvjust = 0.5,
      ylab = dimColnames[2],
      ylabAngle = 0,
      ylabhjust = 0.5,
      ylabvjust = 0.5,
      axisLabSize = 16,
      stripLabSize = 16,
      title = "Individual marker expression",
      subtitle = "",
      caption = ifelse(is(indata, "SingleCellExperiment"), paste0("Total cells, ",
        nrow(as.data.frame(reducedDim(indata, reducedDim)))), paste0("Total cells, ",
        nrow(layout))),
      titleLabSize = 16,
      subtitleLabSize = 12,
      captionLabSize = 12,
      hline = NULL,
      hlineType = "longdash",
      hlineCol = "black",
      hlineWidth = 0.4,
      vline = NULL,
      vlineType = "longdash",
      vlineCol = "black",
      vlineWidth = 0.4,
      gridlines.major = TRUE,
      gridlines.minor = TRUE,
      borderWidth = 0.8,
      borderColour = "black"
    )

### 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`.
`layout` | If 'indata' is a non-SingleCellExperiment object, `layout` must be activated and relate to a 2-dimensional reduction / embedding, although, technically, any data-frame or matrix of numbers will be accepted, provided that it aligns with the dimensions of `indata`, and provided that it contains columns as specified in `dimColnames`.
`assay` | Name of the assay slot in 'indata' from which data will be taken, assuming `indata` is a `SingleCellExperiment` object.
`reducedDim` | A reduced dimensional component stored within `indata`, e.g., PCA or UMAP.
`dimColnames` | The column names of the dimensions to use.
`markers` | Vector containing marker names to plot.
`ncol` | Number of columns for faceting.
`nrow` | Number of rows for faceting.
`col` | Colours used for generation of fill gradient according to expression values. Can be 2 or 3 colours.
`colMidpoint` | Mid-point (expression value) for the colour range. Only used when 3 colours are specified by `col`.
`alpha` | Control the gradient of colour transparency, with 1 being opaque.
`pointSize` | Size of plotted points.
`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.
`celllab` | A vector containing any cells that the user wishes to label in the plot.
`labSize` | Size of labels.
`labhjust` | Horizontal adjustment of label.
`labvjust` | Vertical adjustment of label.
`drawConnectors` | Logical, indicating whether or not to connect plot labels to their corresponding points by line connectors.
`widthConnectors` | Line width of connectors.
`colConnectors` | Line colour of connectors.
`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 (marker) 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.
`hline` | Draw one or more horizontal lines passing through this/these values on y-axis. For single values, only a single numerical value is necessary. For multiple lines, pass these as a vector, e.g., c(60,90).
`hlineType` | Line type for hline `('blank', 'solid', 'dashed', 'dotted', 'dotdash', 'longdash', 'twodash')`.
`hlineCol` | Colour of hline.
`hlineWidth` | Width of hline.
`vline` | Draw one or more vertical lines passing through this/these values on x-axis. For single values, only a single numerical value is necessary. For multiple lines, pass these as a vector, e.g., c(60,90).
`vlineType` | Line type for vline `('blank', 'solid', 'dashed', 'dotted', 'dotdash', 'longdash', 'twodash')`.
`vlineCol` | Colour of vline.
`vlineWidth` | Width of vline.
`gridlines.major` | Logical, indicating whether or not to draw major gridlines.
`gridlines.minor` | Logical, indicating whether or not to draw minor gridlines.
`borderWidth` | Width of the border on the x and y axes.
`borderColour` | Colour of the border on the x and y axes.

### Details

Highlight the individual marker expression profile across a 2-dimensional reduction / embedding, typically contained within a `SingleCellExperiment` object. By default, this function plots the expression profile of 6 randomly-selected markers from your data.

### Value

A `ggplot2` object.

### Author(s)

Kevin Blighe <kevin@clinicalbioinformatics.co.uk>

### Examples

    # create random data that follows a negative binomial
    mat <- jitter(matrix(
    MASS::rnegbin(rexp(1000, rate=.1), theta = 4.5),
      ncol = 20))
    colnames(mat) <- paste0('CD', 1:ncol(mat))
    rownames(mat) <- paste0('cell', 1:nrow(mat))

    u <- umap::umap(mat)$layout
    colnames(u) <- c('UMAP1','UMAP2')
    rownames(u) <- rownames(mat)

    markerExpression(t(mat), layout = u)

[Package scDataviz version 1.0.0 Index]