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-10-31 06:42:27 UTC |
Source: | https://github.com/bioc/traviz |
This object contains the gene expression counts from the data described in Paul et al. (2015).
data("counts", package = "traviz")
data("counts", package = "traviz")
An object of class standardGeneric
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
This dataset contains the Slingshot trajectory from the data described in Paul et al. (2015).
data("crv", package = "traviz")
data("crv", package = "traviz")
An object of class SlingshotDataSet
of length 1.
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
Tools for visualizing lineages inferred by slingshot
.
## 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), ...)
## 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), ...)
x |
a |
type |
character, the type of output to be plotted, can be one of
|
linInd |
integer, an index indicating which lineages should be plotted
(default is to plot all lineages). If |
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 |
asp |
numeric, the y/x aspect ratio, see |
cex |
numeric, amount by which points should be magnified, see
|
lwd |
numeric, the line width, see |
col |
character or numeric, color(s) for lines, see |
... |
additional parameters to be passed to |
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.
returns NULL
.
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)
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)
Tools for visualizing lineages inferred by slingshot
.
## S3 method for class 'SlingshotDataSet' plot3d( x, type = NULL, linInd = NULL, add = FALSE, dims = seq_len(3), aspect = "iso", size = 10, col = 1, ... )
## S3 method for class 'SlingshotDataSet' plot3d( x, type = NULL, linInd = NULL, add = FALSE, dims = seq_len(3), aspect = "iso", size = 10, col = 1, ... )
x |
a |
type |
character, the type of output to be plotted, can be one of
|
linInd |
integer, an index indicating which lineages should be plotted
(default is to plot all lineages). If |
add |
logical, indicates whether the output should be added to an existing plot. |
dims |
numeric, which dimensions to plot (default is |
aspect |
either a logical indicating whether to adjust the aspect ratio
or a new ratio, see |
size |
numeric, size of points for MST (default is |
col |
character or numeric, color(s) for lines, see |
... |
additional parameters to be passed to |
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.
returns NULL
.
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)
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.
Plots a fast loess smoother of gene expression for each lineage.
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 )
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 )
counts |
The matrix of gene expression counts. |
sds |
A |
gene |
Gene name of gene to plot. |
... |
parameters including: |
type |
The type of smoother. Defaults to |
span |
If |
alpha |
Numeric between 0 and 1, determines the transparency of data points,
see |
lwd |
Line width of the smoother. Passed to |
size |
Character expansion of the data points. Passed to |
A ggplot
object.
library(ggplot2) data(crv, package="traviz") data(counts, package="traviz") plotExpression(counts = counts, sds=crv, gene=rownames(counts)[1])
library(ggplot2) data(crv, package="traviz") data(counts, package="traviz") plotExpression(counts = counts, sds=crv, gene=rownames(counts)[1])
Plot the gene in reduced dimensional space.
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 )
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 )
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 |
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 |
The assignation of each cell to a cluster. Used to color the
plot. Either |
models |
The fitted GAMs, typically the output from
|
title |
Title for the plot. |
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.
A ggplot
object
set.seed(97) library(slingshot) data(crv, package="traviz") data(counts, package="traviz") plotGeneCount(crv, counts, gene = "Mpo")
set.seed(97) library(slingshot) data(crv, package="traviz") data(counts, package="traviz") plotGeneCount(crv, counts, gene = "Mpo")
Plot the smoothers estimated by tradeSeq
.
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 )
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 )
models |
Either the |
... |
parameters including: |
nPoints |
The number of points used to extrapolate the fit. Defaults to 100. |
lwd |
Line width of the smoother. Passed to |
size |
Character expansion of the data points. Passed to |
xlab |
x-axis label. Passed to |
ylab |
y-axis label. Passed to |
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 |
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 |
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? |
A ggplot
object
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)
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)
This object contains fitted smoothers using tradeSeq
.
data("sce", package = "traviz")
data("sce", package = "traviz")
An object of class SingleCellExperiment
with 240 rows and 2660 columns.
#' @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