orderCells | R Documentation |
Compute a pseudotime for each cell lying on each path through the MST from a given starting node.
orderCells(mapping, mst, start = NULL)
mapping |
A DataFrame of MST-mapping information for each cell,
usually obtained by running |
mst |
A graph object containing a MST from |
start |
A character vector specifying the starting node from which to compute pseudotimes in each component of |
The pseudotimes are returned as a matrix where each row corresponds to cell in x
and each column corresponds to a path through the MST from start
to all nodes of degree 1.
(If start
is itself a node of degree 1, then paths are only considered to all other such nodes.)
This format is inspired by that from the slingshot package and provides a compact representation of branching events.
Each branching event in the MST results in a new path and thus a new column in the pseudotime matrix.
An NA
entry for a cell indicates that it is not assigned to that particular path.
All non-NA
entries for any given cell are guaranteed to be identical.
This reflects the fact that multiple paths will share a section of the MST for which the pseudotimes are the same.
If start=NULL
, the starting node is completely arbitrarily chosen as directionality is impossible to infer from the expression matrix alone.
However, it is often possible to use prior biological knowledge to pick an appropriate cluster as the starting node.
A PseudotimeOrdering object where rows are cells and columns are paths through mst
.
The first entry of pathStats
contains a numeric matrix with the pseudotimes of each cell in each path.
The cellData
contains mapping
and the metadata
contains the chosen start
.
Aaron Lun
Ji Z and Ji H (2016). TSCAN: Pseudo-time reconstruction and evaluation in single-cell RNA-seq analysis. Nucleic Acids Res. 44, e117
mapCellsToEdges
, to compute mapping
.
quickPseudotime
, a wrapper to quickly perform these calculations.
# Mocking up a Y-shaped trajectory.
centers <- rbind(c(0,0), c(0, -1), c(1, 1), c(-1, 1))
rownames(centers) <- seq_len(nrow(centers))
clusters <- sample(nrow(centers), 1000, replace=TRUE)
cells <- centers[clusters,]
cells <- cells + rnorm(length(cells), sd=0.5)
# Creating the MST and mapping the cells.
mst <- createClusterMST(cells, clusters=clusters)
mapping <- mapCellsToEdges(cells, mst, clusters=clusters)
# Obtaining pseudo-time orderings.
ordering <- orderCells(mapping, mst)
unified <- rowMeans(pathStat(ordering), na.rm=TRUE)
plot(cells[,1], cells[,2], col=topo.colors(21)[cut(unified, 21)], pch=16)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.