plotReducedDimLR: Show ligand-receptor gene expression in reduced dimensions

View source: R/func_sc.R

plotReducedDimLRR Documentation

Show ligand-receptor gene expression in reduced dimensions

Description

This function produces a figure to show the gene expression intensity of a ligand-receptor pair on a pre-calculated low-dimensional projection (such as UMAP or t-SNE).

Usage

plotReducedDimLR(
  sce,
  dimname = "TSNE",
  lr_pair,
  lr_desc = c("Ligand", "Receptor"),
  lr_color = c("blue", "red"),
  lr_sep = "-",
  oneplot = TRUE,
  exprs_by = "logcounts",
  same_scale = TRUE,
  low_color = "gray90",
  point_size = 2,
  point_alpha = 0.5,
  point_shape = 16,
  guides_barwidth = NULL,
  guides_barheight = NULL,
  text_by = NULL,
  theme_size = 18,
  ...
)

Arguments

sce

A SingleCellExperiment object.

dimname

A string or integer scalar indicating the reduced dimension result in reducedDims(sce) to plot. Default is "TSNE".

lr_pair

A character vector of length 2 containing the ligand and receptor gene symbol.

lr_desc

A character vector of length 2 containing short description to change legend title. Default is c("Ligand","Receptor").

lr_color

A character vector of length 2 containing colour aesthetics. Default is c("blue","red").

lr_sep

A character string to define how the 2 genes terms are separated. Default is "-".

oneplot

Logical scalar indicating whether to overlay expressions and produce a single plot or produces two side-by-side plots. Default is TRUE.

exprs_by

A string or integer scalar indicating which assay to obtain expression values from, for use in point aesthetics. Default is "logcounts".

same_scale

Logical scalar indicating whether to use same scale limits on both genes. Default is TRUE.

low_color

A string containing the color code to indicate the colour on the lower-end of the colour scale. Default is "gray90".

point_size

A numeric scalar indicating the size of the points. Default is 2.

point_alpha

A numeric scalar (between 0 and 1) indicating the transparency. Default is 0.5.

point_shape

An integer scalar (between 0 and 25) indicating the shape aesthetics. Also accepts an integer vector length 2 to use different shape on the two plots. Default is 16.

guides_barwidth, guides_barheight

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

text_by

A string indicating the column metadata field with which to add text labels on the plot. Default is NULL.

theme_size

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

...

Other arguments passed on to add_label().

Details

The function is based on plotReducedDim() from the scater package, and uses new_scale_colour() from the ggnewscale package to add an additional layer where a second geom uses another colour scale to show the expression intensity of a second gene.

Even though plotReducedDimLR() was designed initially to show ligand- receptor expression, by changing the lr_desc and lr_sep arguments, one can also use this function to show the expression of two genes, that could be expressed in a mutually exclusive fashion, or specific to certain cell clusters or cell types.

If it is too difficult to visualise the expression of two colour scales on the same figure, one can use oneplot = FALSE to create a compound figure with 2 sub-plots, each showing their respective colours.

Value

A ggplot object when oneplot = TRUE or a ggplot2 plot with an object of class c("gg", "ggplot") when oneplot = FALSE

Author(s)

I-Hsuan Lin

See Also

scater::plotReducedDim(), ggnewscale::new_scale_colour()

Examples

# Load demo dataset
data(sce)

# Plot TSNE on 2 genes
plotReducedDimLR(sce, "TSNE", c("VWF23", "VVU55"))

# Customise annotation
plotReducedDimLR(sce, "TSNE", c("OOX46", "BFP78"),
  lr_desc = c("B", "D"), lr_sep = " and ", text_by = "label"
)

# Show 2 plots
plotReducedDimLR(sce, "TSNE", c("OOX46", "BFP78"),
  lr_desc = c("Grp B", "Grp D"), lr_sep = " and ", text_by = "label",
  guides_barheight = 10, oneplot = FALSE
)

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