orderCells: Compute pseudotimes from the MST

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/orderCells.R

Description

Compute a pseudotime for each cell lying on each path through the MST from a given starting node.

Usage

1
orderCells(mapping, mst, start = NULL)

Arguments

mapping

A DataFrame of MST-mapping information for each cell, usually obtained by running mapCellsToEdges with the per-cell coordinate matrix and mst.

mst

A graph object containing a MST from createClusterMST. This need not be generated from the same cells in mapping.

start

A character vector specifying the starting node from which to compute pseudotimes in each component of mst. Defaults to an arbitrarily chosen node of degree 1 or lower in each component.

Details

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.

The starting node in start is completely arbitrarily chosen by orderClusterMST, 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.

Value

A numeric matrix containing the pseudotimes of all cells (rows) across all paths (columns) through mst.

Author(s)

Aaron Lun

References

Ji Z and Ji H (2016). TSCAN: Pseudo-time reconstruction and evaluation in single-cell RNA-seq analysis. Nucleic Acids Res. 44, e117

See Also

mapCellsToEdges, to compute mapping.

quickPseudotime, a wrapper to quickly perform these calculations.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# 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(ordering, na.rm=TRUE)
plot(cells[,1], cells[,2], col=topo.colors(21)[cut(unified, 21)], pch=16)

TSCAN documentation built on Nov. 8, 2020, 5:13 p.m.