Package 'traviz'

Title: Trajectory functions for visualization and interpretation.
Description: traviz provides a suite of functions to plot trajectory related objects from Bioconductor packages. It allows plotting trajectories in reduced dimension, as well as averge gene expression smoothers as a function of pseudotime. Asides from general utility functions, traviz also allows plotting trajectories estimated by Slingshot, as well as smoothers estimated by tradeSeq. Furthermore, it allows for visualization of Slingshot trajectories using ggplot2.
Authors: Hector Roux de Bezieux [aut, ctb], Kelly Street [aut, ctb], Koen Van den Berge [aut, cre]
Maintainer: Koen Van den Berge <[email protected]>
License: MIT + file LICENSE
Version: 1.13.0
Built: 2024-11-27 05:27:12 UTC
Source: https://github.com/bioc/traviz

Help Index


A count matrix, used for testing.

Description

This object contains the gene expression counts from the data described in Paul et al. (2015).

Usage

data("counts", package = "traviz")

Format

An object of class standardGeneric of length 1.

Details

#' @references Franziska Paul, Yaara Arkin, Amir Giladi, DiegoAdhemar Jaitin, Ephraim Kenigsberg, Hadas KerenShaul, Deborah Winter, David Lara-Astiaso, Meital Gury, Assaf Weiner, Eyal David, Nadav Cohen, FeliciaKathrineBratt Lauridsen, Simon Haas, Andreas Schlitzer, Alexander Mildner, Florent Ginhoux, Steen Jung, Andreas Trumpp, BoTorben Porse, Amos Tanay, and Ido Amit. Transcriptional Heterogeneity and Lineage Commitment in Myeloid Progenitors. Cell, 163(7):1663–1677, 12 2015. ISSN 0092- 8674. doi: 10.1016/J.CELL.2015.11.013. URL https://www.sciencedirect.com/science/article/ ii/S0092867415014932?via


A SlingshotDataset object, used for testing.

Description

This dataset contains the Slingshot trajectory from the data described in Paul et al. (2015).

Usage

data("crv", package = "traviz")

Format

An object of class SlingshotDataSet of length 1.

References

Franziska Paul, Yaara Arkin, Amir Giladi, DiegoAdhemar Jaitin, Ephraim Kenigsberg, Hadas KerenShaul, Deborah Winter, David Lara-Astiaso, Meital Gury, Assaf Weiner, Eyal David, Nadav Cohen, FeliciaKathrineBratt Lauridsen, Simon Haas, Andreas Schlitzer, Alexander Mildner, Florent Ginhoux, Steen Jung, Andreas Trumpp, BoTorben Porse, Amos Tanay, and Ido Amit. Transcriptional Heterogeneity and Lineage Commitment in Myeloid Progenitors. Cell, 163(7):1663–1677, 12 2015. ISSN 0092- 8674. doi: 10.1016/J.CELL.2015.11.013. URL https://www.sciencedirect.com/science/article/ ii/S0092867415014932?via


Plot Slingshot output

Description

Tools for visualizing lineages inferred by slingshot.

Usage

## S4 method for signature 'SlingshotDataSet,ANY'
plot(
  x,
  type = NULL,
  linInd = NULL,
  show.constraints = FALSE,
  add = FALSE,
  dims = seq_len(2),
  asp = 1,
  cex = 2,
  lwd = 2,
  col = 1,
  ...
)

## S4 method for signature 'SlingshotDataSet'
lines(x, type = NULL, dims = seq_len(2), ...)

Arguments

x

a SlingshotDataSet with results to be plotted.

type

character, the type of output to be plotted, can be one of "lineages", "curves", or "both" (by partial matching), see Details for more.

linInd

integer, an index indicating which lineages should be plotted (default is to plot all lineages). If col is a vector, it will be subsetted by linInd.

show.constraints

logical, whether or not the user-specified initial and terminal clusters should be specially denoted by green and red dots, respectively.

add

logical, indicates whether the output should be added to an existing plot.

dims

numeric, which dimensions to plot (default is 1:2).

asp

numeric, the y/x aspect ratio, see plot.window.

cex

numeric, amount by which points should be magnified, see par.

lwd

numeric, the line width, see par.

col

character or numeric, color(s) for lines, see par.

...

additional parameters to be passed to lines.

Details

If type == 'lineages', straight line connectors between cluster centers will be plotted. If type == 'curves', simultaneous principal curves will be plotted.

When type is not specified, the function will first check the curves slot and plot the curves, if present. Otherwise, lineages will be plotted, if present.

Value

returns NULL.

Examples

library(slingshot)
data("slingshotExample", package="slingshot")
rd <- slingshotExample$rd
cl <- slingshotExample$cl
pto <- slingshot(rd, cl, start.clus = "1")
plot(SlingshotDataSet(pto), type = 'b')

# add to existing plot
sds <- as.SlingshotDataSet(pto)
plot(rd, col = 'grey50', asp = 1)
lines(sds, lwd = 3)

Plot Slingshot output in 3D

Description

Tools for visualizing lineages inferred by slingshot.

Usage

## S3 method for class 'SlingshotDataSet'
plot3d(
  x,
  type = NULL,
  linInd = NULL,
  add = FALSE,
  dims = seq_len(3),
  aspect = "iso",
  size = 10,
  col = 1,
  ...
)

Arguments

x

a SlingshotDataSet with results to be plotted.

type

character, the type of output to be plotted, can be one of "lineages", curves, or both (by partial matching), see Details for more.

linInd

integer, an index indicating which lineages should be plotted (default is to plot all lineages). If col is a vector, it will be subsetted by linInd.

add

logical, indicates whether the output should be added to an existing plot.

dims

numeric, which dimensions to plot (default is 1:3).

aspect

either a logical indicating whether to adjust the aspect ratio or a new ratio, see plot3d.

size

numeric, size of points for MST (default is 10), see plot3d.

col

character or numeric, color(s) for lines, see par.

...

additional parameters to be passed to lines3d.

Details

If type == 'lineages', straight line connectors between cluster centers will be plotted. If type == 'curves', simultaneous principal curves will be plotted.

When type is not specified, the function will first check the curves slot and plot the curves, if present. Otherwise, lineages will be plotted, if present.

Value

returns NULL.

Examples

library(rgl)
library(slingshot)
data("crv", package="traviz")
rd <- slingReducedDim(crv)
rd <- cbind(rd, rnorm(nrow(rd), sd=.1))
cl <- apply(slingClusterLabels(crv), 1, which.max)
sds <- slingshot::slingshot(rd, clusterLabels=cl, start.clus=1)
slingshot::plot3d.SlingshotDataSet(as.SlingshotDataSet(sds), type = 'b')

# add to existing plot
plot3d(rd, col = cl, aspect = 'iso')
slingshot::plot3d.SlingshotDataSet(as.SlingshotDataSet(sds), lwd = 3, add = TRUE)

Plot gene expression along pseudotime.

Description

Plot gene expression along pseudotime.

Plots a fast loess smoother of gene expression for each lineage.

Usage

plotExpression(counts, sds, gene, ...)

## S4 method for signature 'matrix,SlingshotDataSet,character'
plotExpression(
  counts,
  sds,
  gene,
  type = "loess",
  span = 0.75,
  alpha = 1,
  lwd = 1,
  size = 2/3
)

## S4 method for signature 'matrix,PseudotimeOrdering,character'
plotExpression(
  counts,
  sds,
  gene,
  type = "loess",
  span = 0.75,
  alpha = 1,
  lwd = 1,
  size = 2/3
)

Arguments

counts

The matrix of gene expression counts.

sds

A SlingshotDataSet or PseudotimeOrdering object, typically obtained after trajectory inference using Slingshot.

gene

Gene name of gene to plot.

...

parameters including:

type

The type of smoother. Defaults to "loess".

span

If type is "loess", the span of the smoother. See loess documentation.

alpha

Numeric between 0 and 1, determines the transparency of data points, see scale_color_viridis_d.

lwd

Line width of the smoother. Passed to geom_line.

size

Character expansion of the data points. Passed to geom_point.

Value

A ggplot object.

Examples

library(ggplot2)
data(crv, package="traviz")
data(counts, package="traviz")
plotExpression(counts = counts, sds=crv, gene=rownames(counts)[1])

Plot gene expression in reduced dimension.

Description

Plot the gene in reduced dimensional space.

Usage

plotGeneCount(curve, ...)

## S4 method for signature 'SlingshotDataSet'
plotGeneCount(
  curve,
  counts = NULL,
  gene = NULL,
  clusters = NULL,
  models = NULL,
  title = NULL
)

## S4 method for signature 'SingleCellExperiment'
plotGeneCount(
  curve,
  counts = NULL,
  gene = NULL,
  clusters = NULL,
  models = NULL,
  title = NULL
)

Arguments

curve

One of two

...

parameters including:

counts

The count matrix, genes in rows and cells in columns. Only needed if the input is of the type SlingshotDataSet and the gene argument is not NULL.

gene

The name of gene for which you want to plot the count or the row number of that gene in the count matrix. Alternatively, one can specify the clusters argument.

clusters

The assignation of each cell to a cluster. Used to color the plot. Either clusters or gene and counts must be supplied.

models

The fitted GAMs, typically the output from fitGAM. Used to display the knots.

title

Title for the plot.

Details

If both gene and clusters arguments are supplied, the plot will be colored according to gene count level. If none are provided, the function will fail.

Value

A ggplot object

Examples

set.seed(97)
library(slingshot)
data(crv, package="traviz")
data(counts, package="traviz")
plotGeneCount(crv, counts, gene = "Mpo")

Plot the log-transformed counts and the fitted values for a particular gene along all lineages

Description

Plot the smoothers estimated by tradeSeq.

Usage

plotSmoothers(models, ...)

## S4 method for signature 'gam'
plotSmoothers(
  models,
  nPoints = 100,
  lwd = 2,
  size = 2/3,
  xlab = "Pseudotime",
  ylab = "Log(expression + 1)",
  border = TRUE,
  alpha = 1,
  sample = 1
)

## S4 method for signature 'SingleCellExperiment'
plotSmoothers(
  models,
  counts,
  gene,
  nPoints = 100,
  lwd = 2,
  size = 2/3,
  xlab = "Pseudotime",
  ylab = "Log(expression + 1)",
  border = TRUE,
  alpha = 1,
  sample = 1,
  pointCol = NULL,
  curvesCols = NULL,
  plotLineages = TRUE
)

Arguments

models

Either the SingleCellExperiment object obtained after running fitGAM, or the specific GAM model for the corresponding gene, if working with the list output of tradeSeq.

...

parameters including:

nPoints

The number of points used to extrapolate the fit. Defaults to 100.

lwd

Line width of the smoother. Passed to geom_line.

size

Character expansion of the data points. Passed to geom_point.

xlab

x-axis label. Passed to labs.

ylab

y-axis label. Passed to labs.

border

Logical: should a white border be drawn around the mean smoother.

alpha

Numeric between 0 and 1, determines the transparency of data points, see scale_color_viridis_d.

sample

Numeric between 0 and 1, use to subsample the cells when there are too many so that it can plot faster.

counts

The matrix of gene expression counts.

gene

Gene name or row in count matrix of gene to plot.

pointCol

Plotting colors for each cell. Can be either character vector of length 1, denoting a variable in the colData(models) to color cells by, or a vector of length equal to the number of cells.

curvesCols

Plotting colors for each curve Should be a list of colors of the exact same length as the number of curves, i.e. the number of lineages (if there is no conditions) or the number of lineages by the number of conditions. In the second case, the colors are grouped by condition (lineage 1 - condition 1, lineage 1 - condition 2,...).

plotLineages

Logical, should the mean smoothers for each lineage be plotted?

Value

A ggplot object

Examples

set.seed(82)
library(ggplot2)
data(crv, package="traviz")
data(counts, package="traviz")
data(sce, package="traviz")
plotSmoothers(sce, counts, rownames(counts)[1])
# show only one curve
curvesCols <- c("#440154FF", "transparent")
plotSmoothers(sce, counts, rownames(counts)[1], curvesCols = curvesCols,
border = FALSE)
# Show only first curve and cells assigned to first lineage
plotSmoothers(sce, counts, rownames(counts)[1], curvesCols = curvesCols,
  border = FALSE) +
  ggplot2::scale_color_manual(values = curvesCols)

A SingleCellExperiment object, used for testing.

Description

This object contains fitted smoothers using tradeSeq.

Usage

data("sce", package = "traviz")

Format

An object of class SingleCellExperiment with 240 rows and 2660 columns.

Details

#' @references Franziska Paul, Yaara Arkin, Amir Giladi, DiegoAdhemar Jaitin, Ephraim Kenigsberg, Hadas KerenShaul, Deborah Winter, David Lara-Astiaso, Meital Gury, Assaf Weiner, Eyal David, Nadav Cohen, FeliciaKathrineBratt Lauridsen, Simon Haas, Andreas Schlitzer, Alexander Mildner, Florent Ginhoux, Steen Jung, Andreas Trumpp, BoTorben Porse, Amos Tanay, and Ido Amit. Transcriptional Heterogeneity and Lineage Commitment in Myeloid Progenitors. Cell, 163(7):1663–1677, 12 2015. ISSN 0092- 8674. doi: 10.1016/J.CELL.2015.11.013. URL https://www.sciencedirect.com/science/article/ ii/S0092867415014932?via