library(knitr)
The traviz
package was created to collect visualization functions related to trajectory inference. Asides from general purpose functions useful to any user, it also contains visualizations that can be used in a slingshot
, tradeSeq
or condiments
workflow.
First, we will demonstrate functions to visualize a trajectory. Here, we'll work with a trajectory as estimated by Slingshot [@Street2018a]. An example trajectory is provided along with the traviz
package.
Below, we show how one can use the lines
and plot
functions for a SlingshotDataSet
object. We also show how the plotGeneCount
function can be used for a quick visualization of the trajectory.
library(slingshot) library(traviz) data(crv, package = "traviz") class(crv) rd <- slingReducedDim(crv) cl <- apply(slingClusterLabels(crv),1, function(x) which(x==1)) ## Only visualize the trajectory plot(crv) ## Visualize the trajectory on top of cells in reduced space plot(rd, pch=16, col=cl+1, cex=2/3) lines(crv, col="black", lwd=3) ## Visualizing trajectory and clusters using plotGeneCount plotGeneCount(crv, clusters=cl)
The same functions (i.e., plot
and lines
) can also be used to visualize trajectories in 3D space using the rgl
package. This can be done using the plot3d
and lines3d
functions, in similar vein as the 2D visualizations above.
The plotGeneCount
also allows you to visualize the trajectory in reduced space, where
each cell is colored according to its expression of the gene as defined by the gene
argument.
data(counts, package="traviz") plotGeneCount(crv, counts, gene = "Mpo")
The plotExpression
function may be used to visualize gene expression along pseudotime along with a quick smooth estimate of average gene expression. It uses a loess smoother to smooth the raw gene expression values as a function of pseudotime. Note that no between-cell normalization occurs to do the smoothing.
plotExpression(counts=counts, sds=crv, gene="Car1")
If smoothers have been fitted using tradeSeq
, then one can use the plotSmoothers
function to plot the estimated smoothers. Note that here normalization does happen within tradeSeq
, and the smoothers are estimated using a negative binomial count model.
data(sce, package="traviz") plotSmoothers(models = sce, counts = counts, gene = "Elane")
Any comment, question, or feedback is welcome and can be posted as an issue on the traviz repo.
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.